O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cancellation

TAP methods often provide an overload with a CancellationToken parameter that you can use to cancel the ongoing operation. Such an overload only exists if the underlying operation has a meaningful way to abort work. If present, the CancellationToken parameter is passed after the parameters that occur on the corresponding synchronous variant.

For example, if an operation gets asynchronous behavior because it’s processed through a work queue, cancellation can be achieved by deleting the item from the queue if it hasn’t started yet. Another typical example is when the asynchronous operation performs other asynchronous operations which are cancelable. In that case, the CancellationToken is passed down to the underlying operations, providing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required