diff --git a/_rules/1820.md b/_rules/1820.md index 0d2fc1d9..f94fab32 100644 --- a/_rules/1820.md +++ b/_rules/1820.md @@ -1,7 +1,9 @@ --- rule_id: 1820 rule_category: performance -title: Only use `async` for low-intensive long-running activities +title: Only use `async`/`await` for I/O-bound or long-running activities severity: 1 --- -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. +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. + +**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.