We’ve been considering adding a Values property to
System.Threading.ThreadLocal<T>. Values
would return a collection of all current values from all threads (e.g. what
you’d get if you evaluated Value from each thread). This would allow for easy aggregations, and
in fact in our Parallel Extensions Extras we have a ...
We’ve seen a number of folks write the following code to execute
on the UI thread and get unexpected behavior. TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();Task uiTask = Task.Factory.StartNew(delegate{ // … Update UI component; BUG!}, uiScheduler);The issue is that the ...
We’ve been considering adding support for creating completed
Tasks from an existing result. Here’s a
prototypical example of where this could be valuable. void
Task<float> ComputeAsync(...)
{
if (!resultIsCached)
{
return
Task<...
Recall that if exceptions thrown from Task bodies are left unobserved, they will be escalated. In .NET 4, this means that TPL will throw them on the finalizer after the Task objects are available for garbage collection. The UnobservedTaskException event on the TaskScheduler class was added as a last-resort method to observe such ...
Many different kinds of applications can benefit from multi-core parallelism, including add-ins to Microsoft Office. Donny Amalo wrote a paper, PLINQ and Office Add-ins, where he demonstrates how to implement two parallel Microsoft Office add-ins using PLINQ:
(This paper and many more are available through the Parallel Computing ...
Despite the similarity in naming, the System.Threading.Tasks.Parallel class and the System.Activities.Statements.Parallel* activities in WF4 are largely orthogonal in the scenarios they address. However, WF4 activities and the new parallel programming types in .NET 4 can be used together to great advantage.Ling Wo and Cristina Manu wrote ...
With TPL, there are several ways to create and start a new task. One way is to use the constructor for task followed by a call to the Start method, e.g. new Task(...).Start();and the other is by using the StartNew method of TaskFactory, e.g. Task.Factory....
We’ve been very excited about the new debugging windows in Visual Studio 2010, namely Parallel Tasks and Parallel Stacks, as well as the newly revamped Threads window, and thus we’ve talked about them quite a bit. For an overview, you can read the MSDN Magazine article at https://msdn.microsoft.com/en-us/magazine/ee410778.aspx, and Daniel ...
For a relatively advanced feature, I've been surprised how often this question has come up recently. When a task completes, its continuations become available for execution, and by default, a continuation will be scheduled for execution rather than executed immediately. This means that the continuation has to be queued to the ...
(The full set of ParallelExtensionsExtras Tour posts is available here.)
The Task Parallel Library isn’t just about CPU-bound operations. The Task class is a great representation for any asynchronous operation, even those implemented purely as asynchronous I/O.Task’s ability to represent arbitrary asynchronous operations ...