.NET Parallel Programming

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

Processing tasks as they complete

Recently I’ve had several folks ask me about how to process the results of tasks as those tasks complete.A developer will have multiple tasks representing asynchronous operations they’ve initiated, and they want to process the results of these tasks, e.g. List<Task<T>> tasks = …; foreach(var t in tasks...

Async Targeting Pack for Visual Studio 11 now available for .NET 4 and Silverlight 5

We’re happy to announce that you can now download an Async Targeting Pack for Visual Studio 11 that lets you target .NET 4 and Silverlight 5.  The included DLLs address the previously discussed issue of the Visual Studio 11 Beta compilers being incompatible with the AsyncCtpLibrary* DLLs from the Async CTP; with this targeting pack...

Are deadlocks still possible with await?

Developers familiar with parallel programming are also familiar with a wide range of potential problems that can occur when practicing the art.  One of the most well-known issues is “deadlock,” where two or more operations are waiting on each other to complete in a manner such that none of them will be able to complete.I&rsquo...

Overriding Stream Asynchrony

In .NET 4.5 Beta, the Stream class provides multiple virtual methods related to reading and writing: As a developer deriving from Stream, it’s helpful to understand what the base implementations do and when you can and should override them.Read, Write, FlushThe Read, Write, and Flush methods are the core synchronous ...

Do I need to dispose of Tasks?

I get this question a lot: “Task implements IDisposable and exposes a Dispose method.  Does that mean I should dispose of all of my tasks?” SummaryHere’s my short answer to this question: “No.  Don’t bother disposing of your tasks.”Here’s my medium-length answer: “No.  Don&...