.NET Parallel Programming

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

Parallel Extensions and I/O

In this post, we’ll investigate some ways that Parallel Extensions can be used to introduce parallelism and asynchrony to I/O scenarios. Here’s a simple scenario.  I want to retrieve data from a number of web resources. static string[] Resources = new string[] {     "http://www.microsoft.com", "http://www.msdn.com", &...

Cancellation in Parallel Extensions

One of the great features that crosses all of Parallel Extensions types is a consistent approach to cancellation (see https://blogs.msdn.com/pfxteam/archive/2009/05/22/9635790.aspx). In this post we explore some of the ways cancellation is used in Parallel Extensions and explain the guidance we developed. The new cancellation system is a ...

Tasks and the APM Pattern

The Asynchronous Programming Model (APM) in the .NET Framework has been around since .NET 1.0 and is the most common pattern for asynchrony in the Framework.  Even if you’re not familiar with the name, you’re likely familiar with the core of the pattern.  For a given synchronous operation Xyz, the asynchronous version ...

Mechanisms for Creating Tasks

The core entity in the Task Parallel Library around which everything else revolves is System.Threading.Tasks.Task.  The most common way of creating a Task will be through the StartNew method on the TaskFactory class, a default instance of which is exposed through a static property on Task, e.g. var t = Task.Factory.StartNew(() => { &...