C# 14 · Async, errors and resources

Support cancellation

Pass a CancellationToken so callers can stop long operations, for example on a timeout.

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
var text = await http.GetStringAsync(url, cts.Token);

Official C# 14 documentation

More async, errors and resources commands

All async, errors and resources commands · C# 14 cheatsheet

Was this page helpful?