Back to Devexpress

CRR0029 - The ConfigureAwait(true) is called implicitly

coderushforroslyn-119686-static-code-analysis-analyzers-library-crr0029-the-configure-await-true-is-called-implicitly.md

latest1.4 KB
Original Source

CRR0029 - The ConfigureAwait(true) is called implicitly

  • Feb 28, 2025

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

csharp
async Task<string> DemoMethodAsync(CancellationToken token) {
    await Task.Run(() => { }, token); // CRR0029
    return "Hello World";
}
vb
Async Function DemoMethodAsync(ByVal token As CancellationToken) As Task(Of String)
    Await Task.Run(Sub() End Sub, token) ' CRR0029
    Return "Hello World"
End Function

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.

csharp
async Task<string> DemoMethodAsync(CancellationToken token) {
    await Task.Run(() => { }, token).ConfigureAwait(false);
    return "Hello World";
}
vb
Async Function DemoMethodAsync(ByVal token As CancellationToken) As Task(Of String)
    Await Task.Run(Sub() End Sub, token).ConfigureAwait(False)
    Return "Hello World"
End Function

See Also

Suppress Analyzers