Skip to main content

CRR0029 - The ConfigureAwait(true) is called implicitly

This analyzer detects the asynchronous method calls with the await keyword that do not explicitly configure the awaiter with the ConfigureAwait() call.

async Task<string> DemoMethodAsync(CancellationToken token) {
    await Task.Run(() => { }, token);  // CRR0029
    return "Hello World";
}

The default awaiter attempts to restore the await‘s continuation to the original captured context, which can cause a deadlock. In most cases (except for the UI), you do not need to restore the context, so the awaiter should always be configured explicitly.

async Task<string> DemoMethodAsync(CancellationToken token) {
    await Task.Run(() => { }, token).ConfigureAwait(false);
    return "Hello World";
}