The task-based asynchronous pattern

The task-based asynchronous pattern (TAP) is a pattern that's used to represent arbitrary asynchronous operations. The concept of this pattern is to represent asynchronous operations in a method and combine the status of the operation and the API that is used to interact with these operators for them to become a single object. The objects are the Task and Task<TResult> types in the System.Threading.Tasks namespace.

Introducing the Task and Task<TResult> classes

The Task and Task<TResult> classes were announced in .NET Framework 4.0 in order to represent an asynchronous operation. It uses threads that are stored in the thread pool but offers the flexibility of how the task is created. We use the Task class when ...

Get Functional C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.