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...
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 ...
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&...
Every now and then, I get this question: “is it ok to use nested Parallel.For loops?” The short answer is “yes.” As is often the case, the longer answer is, well, longer.
Typically when folks ask this question, they’re concerned about one of two things. First, they’re concerned that each nested loop will assume it “owns ...
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 ...
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...
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...
Thanks to everyone who attended my "The Zen of Async" presentation on Thursday at the MVP Summit. As I've had several requests, here are the slides and code for the talk.
Toub_MVPSummit2012_ZenOfAsync.zip...
At //BUILD/ in September, we blogged about the wealth of new support available for parallelism in the .NET Framework 4.5 Developer Preview. Since then, we’ve been hard at work on the .NET 4.5 Beta. With the beta just released, here are a few interesting and related things that are new or have changed since the Developer ...
In my last past, we looked at building an AsyncLock in terms of an AsyncSemaphore. In this post, we’ll build a more advanced construct, an asynchronous reader/writer lock.An asynchronous reader/writer lock is more complicated than any of the previous coordination primitives we’ve created. It also involves more policy, ...