Skip to main content

CRR0039 - The 'await' expression without cancellation token

This analyzer detects asynchronous method calls without a valid CancellationToken.

await Task.Run(() => { DemoMethodSync(); }).ConfigureAwait(false);

You should use a CancellationToken object with all asynchronous methods to be able to cancel tasks. Refer to the Task Cancellation article for more information.

await Task.Run(() => { DemoMethodSync(); }, cancellationToken).ConfigureAwait(false);