.NET Parallel Programming

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

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

Are you using TPL Dataflow? We’d love to know!

Are you using the new System.Threading.Tasks.Dataflow.dll library, either from its CTPs or from the .NET 4.5 Developer Preview or Beta?  We'd love to hear about it, and if you have time, what your experiences have been (good or bad).  What kind of solution are you building, and how are you using TPL Dataflow in it?  Has the ...

Implementing a simple ForEachAsync, part 2

After my previous post, I received several emails and comments from folks asking why I chose to implement ForEachAsync the way I did.  My goal with that post wasn’t to prescribe a particular approach to iteration, but rather to answer a question I’d received… obviously, however, I didn’t provide enough background...

Implementing a simple ForEachAsync

Jon Skeet recently asked me how I might go about implementing the following “asynchronous ForEach” behavior: Given what we now know about SemaphoreSlim from my previous post, here’s one way to achieve this: public static Task ForEachAsync<TSource, TResult>(     this IEnumerable<TSource...