using System; using System.Threading; using System.Threading.Tasks; internal static class Program { private static async System.Threading.Tasks.Task Main(string[] args) { using var source = new CancellationTokenSource(); source.Cancel(); try { await Task.Delay(10, source.Token); } catch (OperationCanceledException) when (source.IsCancellationRequested) { Console.WriteLine("Request cancelled"); } } }