تخطَّ إلى المحتوى

Async over sync (ARCH104)

هذا المحتوى غير متوفر بلغتك بعد.

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.

public Order GetOrder(int id)
{
return _repository.FindAsync(id).Result;
}
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.