PLINQ and Int32.MaxValue

In both .NET 4 and .NET 4.5, PLINQ supports enumerables with up to Int32.MaxValue elements.  Beyond that limit, PLINQ will throw an overflow exception.  LINQ to Objects itself has this limitation with certain query operators (such as the indexed Select operator which counts the elements processed), but PLINQ has it with more. This limitation impacts… Read more

PLINQ Queries That Run in Parallel in .NET 4.5

One interesting thing to know about PLINQ is that not all queries are guaranteed to execute in parallel (See PLINQ Queries That Run Sequentially for reference). You can think of the AsParallel method as a hint to run in parallel for query shapes that it believes will be faster. By default, PLINQ prefers to use… Read more

What’s New For Parallelism in .NET 4.5

.NET 4 and Visual Studio 2010 saw the introduction of a wide range of new support for parallelism: the Task Parallel Library (TPL), Parallel LINQ (PLINQ), new synchronization and coordination primitives and collections (e.g. ConcurrentDictionary), an improved ThreadPool for handling parallel workloads, new debugger windows, new concurrency visualizations, and more. Since then, we’ve been hard… Read more

PLINQ’s Ordering Model

In order to execute parallel queries as efficiently as possible, Parallel LINQ (PLINQ) treats ordering as optional. By default, PLINQ considers sequences to be unordered, unless the user explicitly opts into maintaining ordering using either the AsOrdered or the OrderBy operator. Roy Patrick Tan wrote a detailed article that explains the precise ordering guarantees made by PLINQ for various… Read more

Lesser-known Multi-threaded Debugging Support in Visual Studio 2010

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, and Daniel Moth has a larger collection… Read more

ParallelExtensionsExtras Tour – #14 – SingleItemPartitioner

(The full set of ParallelExtensionsExtras Tour posts is available here.)  In a previous ParallelExtensionsExtras Tour blog post, we talked about implementing a custom partitioner for BlockingCollection<T>.  Custom partitioning is an advanced but important feature supported by both Parallel.ForEach and PLINQ, as it allows the developer full control over how data is distributed during parallel processing. … Read more

When To Use Parallel.ForEach and When to Use PLINQ

If you’ve played around with PLINQ and Parallel.ForEach loops in .NET 4, you may have noticed that many PLINQ queries can be rewritten as parallel loops, and also many parallel loops can be rewritten as PLINQ queries. However, both parallel loops and PLINQ have distinct advantages in different situations. When writing parallel code, it helps to understand these differences to appropriately… Read more

ParallelExtensionsExtras Tour – #11 – ParallelDynamicInvoke

(The full set of ParallelExtensionsExtras Tour posts is available here.)  Delegates in .NET may have one or more methods in their invocation list.  When you invoke a delegate, such as through the Delegate.DynamicInvoke method, the net result is that all of the methods in the invocation list get invoked, one after the other.  Of course, in… Read more

F# PowerPack supports PLINQ

The F# team has released the F# PowerPack for download on CodePlex, and we’re very excited that the PowerPack now has direct support for PLINQ.  From the CodePlex site: F# Parallel LINQ IntegrationFSharp.PowerPack.Parallel.dll provides an F#-style API for parallel operations on sequences that are part of .NET 4.0 as System.Linq.ParallelEnumerable class. The API is akin… Read more

"Parallelism in .NET" Series by Reed Copsey, Jr.

Reed Copsey, Jr. has been writing a great series of articles on parallelism with the .NET Framework 4. The articles provide the insights of an expert developer who has been using parallelism with .NET to speed up real-world programs. Recommended reading. Parallelism in .NET Introduction Part 1, Decomposition  Part 2, Simple Imperative Data Parallelism Part 3, Imperative Data Parallelism: Early Termination Part… Read more