Click or drag to resize
User Guide

This library provides improved support for writing asynchronous code targeting the .NET Framework 3.5 and newer. Additional information and links to project resources are located on the Welcome page.

Features

The basic features of this library can be described as the following.

  • Extensions and utilities for legacy code: These extension methods provide select features which were added to the Task Parallel Library in .NET 4.5 as extension methods and static utility methods for .NET 3.5 and .NET 4.0 users.

  • Extensions for task continuations: These extension methods allow developers to write task continuations in asynchronous code that behave in similarly to / while maintaining support for .NET 3.5 and .NET 4.0.

  • Task building blocks: These utility methods allow developers to write efficient asynchronous code using high-level block constructs that resemble the methods produced by the keyword while maintaining support for .NET 3.5 and .NET 4.0.

Extension and Utility Methods for Legacy Code

The .NET Framework 4.5 introduces several new methods to simplify the use of the Task Parallel Library in common scenarios. This library provides extension methods and static utility methods for some of the most frequently used cases, allowing use of the functionality in .NET 3.5 and .NET 4.0. These methods are provided by the following classes.

Extension Methods for Task Continuations

The ContinueWith methods provide comprehensive options for writing task continuations, but introduce a number of concerns regarding faulted and canceled tasks. Developers must also be careful regarding the use of the Unwrap method. While the / keywords introduced in C# 5 (and similar keywords in other select programming languages) provide a cleaner development experience, they are not available for users of earlier versions of the language and/or framework. This library provides extension methods to simplify the creation of efficient, "well-behaved" task continuations without requiring the use of /.

Each of the extension methods provided by this library is implemented in a manner that propagates exceptions and/or cancellation closely matching the behavior of code written with /. In particular, care is taken to not wrap single exceptions inside multiple layers of AggregateException.

Task Building Blocks

Task building blocks provide support for block-level programming constructs in asynchronous code. The resulting execution resembles the behavior of the state machines created by the C# compiler to support the / keywords, but does not depend on these features being available. As a result, .NET 3.5 and .NET 4.0 developers can enjoy clean, efficient asynchronous code.

The following blocks are currently supported by this library.