.NET Parallel Programming

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

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,

New “Parallel Computing” dev center on MSDN

There’s a new Parallel Computing developer center on MSDN:

“Microsoft’s Parallel Computing developer center is dedicated to providing information, ideas, community, and technology to developers to make it easier to write programs that perform and scale well on parallel hardware.” 

Check it out! 

PLINQ changes since the MSDN Magazine article

I posted about changes we’ve made to the Task Parallel Library since we published the MSDN Magazine article outlining its design.  In this post, I’ll do the same thing for PLINQ. 
Most of the October 2007 article on PLINQ is still accurate.  

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,

CTP Quality

Community Technology Preview (CTP) releases from Microsoft typically provide early looks at the technologies a team is working on.  Frequently, CTP quality is nowhere near what folks might expect from Beta releases and the like, and that’s ok.  The idea is to give all of you in the community a look at what we’re working on,

Welcome to the Parallel Extensions team blog!

Software is headed for a fundamental change.  Over the last 30 years, developers have relied on exponential growth in computing power in order to dream big.  Your cool new application is too slow today?  No problem, just wait two years and everyone will have computers that run twice as fast. 

Known Correctness Bugs with the Parallel Extensions CTP December 2007

Here are known correctness bugs as of our December 2007 CTP release:


The setup for Parallel Extensions may fail on Windows Server 2008 (both 32-bit and 64-bit).  As a workaround, Parallel Extensions may be installed manually:

From a prompt with administrator privileges: msiexec /a ParallelExtensions_Dec07CTP.msi TARGETDIR=”%TMP%ParallelExtensions”


New Task APIs in .NET 4.6

There are several nice API-level enhancements to the Task Parallel Library in .NET 4.6, which you can grab a preview of as part of the Visual Studio 2015 CTP.
.NET 4.5 had a Task.FromResult method.  This method makes it quick and easy to manufacture a new Task for a known result value,

.NET memory allocation profiling and Tasks

The .NET Framework blog published this morning a guest post from yours truly on .NET Memory Allocation Profiling with Visual Studio 2012.  As you’re trying to improve the performance, throughput, and memory usage of code that uses Tasks, the described profiler in Visual Studio can be a valuable tool in your tool belt (of course,

Tasks, Monads, and LINQ

A few years back, Wes Dyer wrote a great post on monads, and more recently, Eric Lippert wrote a terrific blog series exploring monads and C#. In that series, Eric alluded to Task<TResult> several times, so I thought I’d share a few related thoughts on Task<TResult>

“Invoke the method with await”… ugh!

I can be a bit sensitive when it comes to language and how concepts are conveyed.  I think it’s important to be accurate, even if not precise, when describing what something is or how to use it, as otherwise the folks to whom you’re communicating can easily form the wrong mental model for that thing. 

MVP Summit presentation on async

Lucian Wischik and I presented an “async clinic” at the MVP Summit in Bellevue this week.  The async/await keywords in C# and Visual Basic drastically simplify asynchronous programming, but that of course doesn’t mean that using them is without any gotchas: the goal of the discussion was to highlight some of the key areas in which we see developers struggling with asynchronous development and to help provide guidance on avoiding and overcoming those roadblocks. 

Psychic Debugging of Async Methods

These days it’s not uncommon for me to receive an email or read a forum post from someone concerned about a problem they’re experiencing with an async method they’ve written, and they’re seeking help debugging the issue.  Sometimes plenty of information about the bug is conveyed,

Cooperatively pausing async methods

Recently I was writing an app that processed a bunch of files asynchronously.  As with the Windows copy file dialog, I wanted to be able to provide the user with a button that would pause the processing operation.
To achieve that,

C# memory model articles

Igor Ostrovsky is one of the minds behind the parallel programming support in the .NET Framework.  Igor’s recently written a great set of articles for MSDN Magazine to cover “The C# Memory Model in Theory and Practice“.  Part 1 is available now in the December 2012 issue,

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),

How do I cancel non-cancelable async operations?

This is a question I hear relatively frequently:

“I have an async operation that’s not cancelable.  How do I cancel it?”

The construction of the question often makes me chuckle, but I understand and appreciate what’s really being asked.  The developer typically isn’t asking how to cancel the operation itself (if they are asking that,