Choosing the right path forward
Now that you have been introduced to some advanced managed threading concepts, parallel programming, concurrent collections, and the async/await paradigm, let’s discuss how they all fit together in the real world. Choosing the right path forward with multithreaded development in .NET will usually involve more than one of these concepts.
When working with .NET 6, you should usually choose to create async
methods in your projects. The reasons discussed in this chapter are compelling. Asynchronous programming keeps both client and server applications responsive, and async
is used extensively throughout .NET itself.
Some of the Parallel
class operations can be leveraged when your code needs to process a set of items quickly and the underlying code doing the processing is thread-safe. This is one place where concurrent collections can be introduced. If any parallel or async operations are manipulating shared data, the data should be stored in...