Chapter 11: Canceling Asynchronous Work

In the previous chapters, we’ve looked at a few examples of how to cancel threads and tasks. This chapter will explore more of the methods available to cancel concurrent and parallel work with C# and .NET. The methods in this chapter will provide alternative ways to cancel background operations using callbacks, polling, and wait handles. You will gain a deeper understanding of how to safely cancel asynchronous work with a variety of methods using some practical scenarios.

In this chapter, you will learn about the following topics:

  • Canceling managed threads
  • Canceling parallel work
  • Discovering patterns for thread cancellation
  • Handling multiple cancelation sources

By the end of this chapter, you will understand ...

Get Parallel Programming and Concurrency with C# 10 and .NET 6 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.