Async void (ARCH102)
Ce contenu n’est pas encore disponible dans votre langue.
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.
Incorrect
Section titled “Incorrect”public async void ProcessAsync(){ await _repository.SaveAsync();}Correct
Section titled “Correct”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.