Async over sync (ARCH104)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key dotnet.async.async-over-sync · Severity error · Category async
Avoid blocking on async code with .Result or .Wait(). This can cause deadlocks and exhaust the thread pool.
Incorrect
Section titled “Incorrect”public Order GetOrder(int id){ return _repository.FindAsync(id).Result;}Correct
Section titled “Correct”public async Task<Order> GetOrderAsync(int id){ return await _repository.FindAsync(id);}Make the call chain async end-to-end and use await. If needed, suppress the rule per project/workspace via except/ignore.