Back to Writing
NOTEScsharpasynccancellation-tokenconcurrency

C# - Cancelling Async Operations with CancellationToken

October 19, 2020Updated Feb 17, 2026

![](

R7laTJO2_lMuy9WVk0g.9FAZZBZtuH9aGClhoPwlDZXZKYSoZoYV86ISk82lwkwg.PNG.cdw0424/csharp.png?type=w966)

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().