.NET Parallel Programming

All about Async/Await, System.Threading.Tasks, System.Collections.Concurrent, System.Linq, and more…

Is it ok to use nested Parallel.For loops?

Every now and then, I get this question: “is it ok to use nested Parallel.For loops?” The short answer is “yes.”  As is often the case, the longer answer is, well, longer. Typically when folks ask this question, they’re concerned about one of two things.  First, they’re concerned that each nested loop will assume it “...

ThreadPool performance you can see

We've spent a lot of time touting improvements to the .NET Framework in .NET 4 around threading, including core enhancements to the performance of the runtime itself.  Sometimes data is more powerful than words, however, and it's useful to be able to see exactly what kind of difference such improvements can make.  To assist with that...

ParallelExtensionsExtras Tour – #7 – Additional TaskSchedulers

(The full set of ParallelExtensionsExtras Tour posts is available here.)In our last two ParallelExtensionsExtras blog tour posts, we’ve discussed two TaskScheduler implementations in ParallelExtensionsExtras: StaTaskScheduler and ConcurrentExclusiveInterleave.  These are just 2 of more than 10 schedulers in ParallelExtensionsExtras...

PDC09 Parallelism Session Videos Now Available

Attendees at PDC09 this past week were privy to quite a few sessions on parallel computing.  Now that the videos of these sessions are online, you can view them as well from the comfort of your own home.  Here are some of the key parallelism-related sessions from this past week:Overview The State of Parallel Programming  ...

TaskScheduler.FromCurrentSynchronizationContext

The Task abstractions in .NET 4 run on instances of the TaskScheduler class.  Two implementations of TaskScheduler ship as part of the .NET Framework 4.  The first is the default scheduler, which is integrated with the .NET 4 ThreadPool and takes advantage of its work-stealing queues.  The second is the type of TaskScheduler ...

Tasks and Unhandled Exceptions

Prior to the .NET Framework 2.0, unhandled exceptions were largely ignored by the runtime.  For example, if a work item queued to the ThreadPool threw an exception that went unhandled by that work item, the ThreadPool would eat that exception and continue on its merry way.  Similarly, if a finalizer running on the finalizer thread ...