Back to Writing
NOTEScsharpasynccancellation-tokenconcurrency
C# - Cancelling Async Operations with CancellationToken
October 19, 2020•Updated Feb 17, 2026

CancellationTokenSource tokenSource = new CancellationTokenSource();
await Task.Delay(1000, tokenSource.Token);
// Terminates all async functions using the token
tokenSource.Cancel();
As shown above, any async functions that receive a token from a CancellationTokenSource can be terminated all at once via tokenSource.Cancel().