Chapter 16: Asynchronous Programming
In this chapter, you will learn about the Task-based Asynchronous Pattern (TAP). You will learn how to program tasks asynchronously and how to access web resources using async
, await
, and WhenAll
. You will also learn about different return types and extract the required results. Plus, you will learn how to correctly cancel asynchronous operations and perform asynchronous file reading and writing.
In this chapter, we will be covering the following topics:
- Understanding the TAP model: In this section, we provide a high-level overview of the TAP model.
- Using async, await, and Task: In this section, we will benchmark the performance of a method run synchronously (using
Task.Run
) and asynchronously. - Benchmarking GetAwaiter.GetResult(), .Result, and .Wait for both Task and ValueTask: In this section, we benchmark the performance of an asynchronous operation using
GetAwaiter.GetResult()
,.Result
, and.Wait
for bothTask
andValueTask...