liveBook · Manning

CancellationTokenSource

CancellationTokenSource is a .NET type that creates and controls cancellation signals represented by CancellationToken values.

How 2 Manning books explain it

C# Concurrency: Asynchronous and multithreaded programming

CancellationTokenSource is a .NET object that creates and controls cancellation tokens, including by requesting cancellation.

How it is used
Coordinates cooperative cancellation for background work and asynchronous operations by separating cancellation requests from cancellation checks.
How deep it goes
Explains source-token separation, flag-based observation, delayed cancellation, timeouts, callbacks, and linked sources without detailing token internals.
Examples
Demonstrates cancellable background threads, long calculations, and HTTP requests canceled by either a user token or a timeout.
What you can do after
Operate/configure cooperative cancellation by creating sources, calling Cancel or CancelAfter, linking tokens, and passing tokens to cancelable operations.

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

.NET in Action, Second Edition

CancellationTokenSource is a .NET type that creates and controls cancellation signals represented by CancellationToken values.

How it is used
Coordinates stopping asynchronous file or network work when its result is no longer needed.
How deep it goes
Shows source creation, token checks, and forwarding through async calls; does not show the source being triggered.
Examples
Uses an asynchronous comic search that passes one source’s token to fetching tasks.
What you can do after
Apply it via .NET async APIs to pass a shared cancellation token into HTTP requests and deserialization.

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

Related concepts

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.