Skip to content

Async void (ARCH102)

Key dotnet.async.async-void · Severity error · Category async

Avoid async void methods except for event handlers. Exceptions thrown from async void methods cannot be caught and can crash the application.

public async void ProcessAsync()
{
await _repository.SaveAsync();
}
public async Task ProcessAsync()
{
await _repository.SaveAsync();
}

Change the return type from void to Task. If needed, suppress the rule per project/workspace via except/ignore.