codementor on Nostr: Learn: Task vs Thread A Thread is an operating system thread: expensive to create, ...
Learn: Task vs Thread
A Thread is an operating system thread: expensive to create, and it holds memory the whole time.
A Task is a promise of a result. CPU work started with Task.Run runs on a shared pool of threads. A task waiting for I/O (a web call, a database) holds no thread at all while it waits.
In modern C#, use Task and async/await; create a Thread yourself only for rare long-running, dedicated work.
Read more:
https://learn.microsoft.com/en-us/dotnet/standard/parallel-programming/task-based-asynchronous-programming#tip · TIP-045
Published at
2026-10-16 06:38:04 UTCEvent JSON
{
"id": "10777a585c9ad3827b546ed5e3c89244e2055f9deff49f7a38a8a67706350f07",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1792132684,
"kind": 1,
"tags": [
[
"t",
"tip"
]
],
"content": "Learn: Task vs Thread\n\nA Thread is an operating system thread: expensive to create, and it holds memory the whole time.\nA Task is a promise of a result. CPU work started with Task.Run runs on a shared pool of threads. A task waiting for I/O (a web call, a database) holds no thread at all while it waits.\n\nIn modern C#, use Task and async/await; create a Thread yourself only for rare long-running, dedicated work.\n\nRead more: https://learn.microsoft.com/en-us/dotnet/standard/parallel-programming/task-based-asynchronous-programming\n\n#tip · TIP-045",
"sig": "95b9617a12c7278da5a42d3ed1bb6778e35fea1d26250ece4046ac2005837ca10772c7bc84f73132d878726de1536a7f6e1082c0dcab317557b05faee1f2c480"
}