Skip to content

Commit 34a55f6

Browse files
authored
Update AV1820: Only use async for I/O-bound or long-running activities (#376)
1 parent 34df958 commit 34a55f6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

_rules/1820.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
---
22
rule_id: 1820
33
rule_category: performance
4-
title: Only use `async` for low-intensive long-running activities
4+
title: Only use `async`/`await` for I/O-bound or long-running activities
55
severity: 1
66
---
7-
The usage of `async` won't automagically run something on a worker thread like `Task.Run` does. It just adds the necessary logic to allow releasing the current thread, and marshal the result back on that same thread if a long-running asynchronous operation has completed. In other words, use `async` only for I/O bound operations.
7+
The use of `async`/`await` won't automagically run something on a worker thread as `Task.Run` does. It just suspends execution at the await point and resumes execution after the task has completed. In other words, use `async`/`await` only for I/O-bound operations.
8+
9+
**Exception:** Tasks returned from `Task.Run` (which starts a background operation in parallel) can eventually be awaited to obtain their results, or passed to a method like `Task.WhenAll` that is awaited.

0 commit comments

Comments
 (0)