.NET Parallel Programming

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

Recursion and Concurrency

When teaching recursion in an introductory computer science course, one of the most common examples used involves a tree data structure.  Trees are useful in this regard as they are simple and recursive in nature, with a tree's children also being trees, and allow for teaching different kinds of traversals (in-order, pre-order, post-...

Code Snippets for Parallel.For and Parallel.ForEach

Introduced in Visual Studio 2005, Code Snippets allow you to quickly insert reusable blocks of code into your project.  For example, if you want to quickly write a for loop in C#, you can simply type "for" into your code file, and IntelliSense shows you the "for" code snippet: Now you press the tab key twice, and Visual ...

Chunk partitioning vs range partitioning in PLINQ

If you look in the PLINQ samples in the December 2007 CTP, you'll see a parallel implementation of Luke Hoban's LINQ ray tracer.  The sample parallelizes the ray tracer by changing very few lines of code.   Luke's original query started as follows: from y in Enumerable.Range(0, screenHeight)For our sample, we've changed that to...

Task Parallel Library changes since the MSDN Magazine article

Back in the October 2007 issue of MSDN Magazine, we published an article on the beginning stages of what has become the Task Parallel Library (TPL) that's part of the Parallel Extensions to the .NET Framework.  While the core of the library and the principles behind it have remained the same, as with any piece of software in the ...