Last Updated: May 22, 2026
A long-running async operation that can't be cancelled is a liability. The user closes the tab, the request times out, the server starts shutting down, and your code keeps grinding away on work nobody wants any more. .NET's answer to this is the CancellationToken, a small object that gets passed through async call chains and signals "stop as soon as you can." This lesson covers how cancellation actually works, the difference between CancellationTokenSource and CancellationToken, polling vs throwing, timeouts, linking tokens, and the cleanup mistakes that bite people in production.