IntelliTect Guidelines

IntelliTect's guidlines for coding and architecture. Documentation for IntelliTect's .NET Compiler Platform (Roslyn) Analyzers.


Project maintained by IntelliTect Hosted on GitHub Pages — Theme by mattgraham

O2XX Block - Reliability

INTL0201

Async Void

Async methods must return either Task or Task<T>.

Allowed

public async void SomeTopLevelMethod(object sender, EventArgs e)
{
    // some code
}

public async Task SomeMethod()
{
    // some code
}

Disallowed

public async void SomeMethod()
{
    // some code
}

When to suppress

The only acceptable use of async void is in a top level methods, such as event handlers. For these cases it is safe to suppress this warning. In all other cases, this warning should NOT be suppressed.