.NET Parallel Programming

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

.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, the ...

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> and the async/await keywords.As both Wes and Eric highlight...

“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.  Having a good mental...

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 ...

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, but other times the communication ...

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, I implemented a simple mechanism that would allow me to pass a “pause token” into the async method...

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, and it's a great read...

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 ...

New TaskCreationOptions and TaskContinuationOptions in .NET 4.5

Astute users of the Task Parallel Library might have noticed three new options available across TaskCreationOptions and TaskContinuationOptions in .NET 4.5: DenyChildAttach, HideScheduler, and (on TaskContinuationOptions) LazyCancellation.  I wanted to take a few minutes to share more about what these are and why we added them....