Skip to content

Commit 77987d5

Browse files
dennisdoomenDennis DoomenCopilot
authored
Update AV1825 guideline (#377)
Split from #298. Co-authored-by: Dennis Doomen <dennis.doomen@greenchoice.nl> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 96303be commit 77987d5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

_rules/1825.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
---
22
rule_id: 1825
33
rule_category: performance
4-
title: Prefer `Task.Run` or `Task.Factory.StartNew` for CPU-intensive activities
4+
title: Prefer `Task.Run` for CPU-intensive activities
55
severity: 1
66
---
7-
If you do need to execute a CPU bound operation, use `Task.Run` to offload the work to a thread from the Thread Pool. For long-running operations use `Task.Factory.StartNew` with `TaskCreationOptions.LongRunning` parameter to create a new thread. Remember that you have to marshal the result back to your main thread manually.
7+
If you need to execute a CPU-bound operation, use `Task.Run` to offload the work to a thread from the Thread Pool. Remember that you have to marshal the result back to your main thread manually.
8+
9+
For long-running operations, use `Task.Factory.StartNew` with `TaskCreationOptions.LongRunning` to hint the runtime to use a dedicated thread instead of a thread pool thread.

0 commit comments

Comments
 (0)