15Asynchronous Programming

WHY ASYNCHRONOUS PROGRAMMING IS IMPORTANT

The .NET Framework 4.5 added the Task Parallel Library (TPL) to .NET to make parallel programming easier. C# 5.0 added two keywords to make asynchronous programming easier: async and await. These two keywords are the main focus of this chapter.

With asynchronous programming a method is called that runs in the background (typically with the help of a thread or task), and the calling thread is not blocked.

In this chapter, you can read about different patterns on asynchronous programming such as the asynchronous pattern, the event-based asynchronous pattern, and the task-based asynchronous pattern (TAP). TAP makes use of the async and await keywords. When you compare these patterns, you can see the real advantage of this style of asynchronous programming.

After discussing the different patterns, you see the ...

Get Professional C# 7 and .NET Core 2.0, 7th Edition 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.