February 2025
Intermediate to advanced
248 pages
6h 36m
English
This chapter covers
CancellationToken and Cancellation-TokenSource classesIn the previous chapter, we talked about how to run stuff in the background. In this chapter, we are going to talk about how to make it stop. The .NET library provides a standard mechanism for signaling that a background operation should end, which is called CancellationToken. The CancellationToken class is used consistently for (almost) all cancelable operations in the .NET library itself and in most third-party libraries.
For this chapter, we need an example of a long-running operation we can cancel. So let’s write a short program ...
Read now
Unlock full access