April 2013
Intermediate to advanced
1700 pages
92h 51m
English
One thing that has been notoriously difficult in the world of asynchronous code (among other things, such as other threading and synchronization constructs) is the means to cancel an operation. Starting with .NET 4.0, cancellation has been unified in terms of two concepts: CancellationToken and CancellationTokenSource.
We don’t elaborate on the intricacies of the mechanism here but instead focus on the essentials of the feature. Figure 30.6 summarizes the basic interactions with constructs for cancellation.
FIGURE 30.6 Cancellation of a task.
The first key notion is that of a CancellationTokenSource. This class is where ...
Read now
Unlock full access