liveBook · Manning

CancellationToken

Also called cancellation token

CancellationToken is a .NET value that communicates a cooperative request to cancel an asynchronous or otherwise cancellable operation.

How 2 Manning books explain it

C# Concurrency: Asynchronous and multithreaded programming

A CancellationToken is a .NET value that communicates a request to cancel an asynchronous or otherwise cancellable operation.

How it is used
Coordinates cooperative cancellation for background threads, asynchronous operations, and asynchronous iteration.
How deep it goes
Explains source-token separation, polling, delayed cancellation, callbacks, timeouts, linked sources, and async-iterator propagation.
Examples
Demonstrates cancelable background loops, long calculations, Task.Delay, async iterators, and await foreach with WithCancellation.
What you can do after
Apply it via .NET APIs to design cooperative cancellation and propagate requests through long-running and asynchronous workflows.

Read how C# Concurrency: Asynchronous and multithreaded programming explains CancellationToken →

.NET in Action, Second Edition

A cancellation token is a .NET value that communicates a cooperative request for an operation to stop.

How it is used
Coordinates stopping unwanted asynchronous I/O work, including requests made during a title search.
How deep it goes
Shows an explicit parameter, a pre-request check, and token propagation into HTTP and JSON APIs.
Examples
Uses an asynchronous comic lookup and a search that shares a token across lookup tasks.
What you can do after
Apply it by accepting a token, checking for cancellation, and passing it to asynchronous operations.

Read how .NET in Action, Second Edition explains CancellationToken →

Also covered in

Related concepts

Questions about CancellationToken

What is CancellationToken?

CancellationToken is a .NET value that communicates a cooperative request to cancel an asynchronous or otherwise cancellable operation.

Which Manning books explain CancellationToken?

C# Concurrency: Asynchronous and multithreaded programming and .NET in Action, Second Edition.

What kinds of CancellationToken are there?

Kinds of CancellationToken include CancellationToken.None.

What is CancellationToken also called?

CancellationToken is also called cancellation token.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.