C# 7 and .NET Core 2.0 High Performance
上QQ阅读APP看书,第一时间看更新

Multithreading and Asynchronous Programming in .NET Core

Multithreading and asynchronous programming are two essential techniques that facilitate the development of highly scalable and performant applications. If the application is not responsive, it affects the user experience and increases the level of dissatisfaction. On the other hand, it also increases the resource usage on the server side, or where the application is running, and also increases the memory size and/or CPU usage. Nowadays, hardware is very cheap, and every machine comes with multiple CPU cores. Implementing multithreading and using asynchronous programming techniques not only increases the performance of the application, but also makes the application more responsive in nature.

This chapter examines the core concepts of multithreading and the asynchronous programming model to help you use them in your projects and increase the overall performance of your applications.

The following is a list of the topics that we will learn about in this chapter:

  • Multithreading versus asynchronous programming
  • Multithreading in .NET Core
  • Threads in .NET Core
  • Thread synchronization
  • Task parallel library (TPL)
  • Creating a task using TPL
  • Task-based asynchronous pattern
  • Design patterns for parallel programming
I/O bound operations are code that is dependent on external resources. Examples include  accessing a  filesystem, accessing a network, and so on.