Understanding the TAP model
Before we begin, it is worth noting that there are three different models for dealing with asynchronous programming. These are as follows:
- The Asynchronous Programming Model (APM)
- The Event-Based Asynchronous Pattern (EAP) model
- The Task Parallelism Library (TPL)
APM uses BeginMethod to start the asynchronous process and EndMethod to complete the asynchronous process. EAP uses MethodAsync to start an asynchronous process, CancelAsync to handle the cancellation of an asynchronous operation, and a completed event handler to handle the completed asynchronous operation. Both these ways of performing asynchronous operations were replaced by TPL in C# 4.5.
TPL uses the async and await pattern. Asynchronous method names are suffixed with async. An asynchronous method usually returns an awaitable Task or Task<Result>. From .NET 4.5 onwards, you are advised to use TPL instead of using APM and EAP.
TAP's foundation types are...