An async method waits with Task.WaitAll or Task.WaitAny, which block the thread where WhenAll and WhenAny would await
What it finds
Task.WaitAll holds the calling thread until every task is done, which defeats the purpose of an async method and can deadlock under a synchronization context. await Task.WhenAll(...) waits without blocking.
From the rule's source, blocking_wait_all_in_async.rs.
using System.Threading.Tasks; class Batch{ async Task Run(Task a, Task b) { Task.WaitAll(a, b);tx0 reports: Task.WaitAll blocks inside an async method await Task.WhenAll(a, b); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:blocking-wait-all-in-async" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:blocking-wait-all-in-async] reason="..."tx0 explain tx0/csharp:blocking-wait-all-in-async shows the same in the terminal. Found a false positive? Report it.