using System.Threading.Tasks;
static async Task Main(string[] args)
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(5));
await RequestUtrn(10, cts.Token).WaitAsync(cts.Token);
catch (OperationCanceledException)
Console.WriteLine("Operation cancelled.");
static async Task<string> RequestUtrn(int secondsDelay, CancellationToken cancellationToken)
while (iterations != secondsDelay)
cancellationToken.ThrowIfCancellationRequested();
Console.WriteLine($"....{iterations}");
await Task.Delay(TimeSpan.FromSeconds(1));