Home / Forums / Difference between Task.Run and ThreadPool.QueueUserWorkItem in modern .NET? [Discussion #4]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

Difference between Task.Run and ThreadPool.QueueUserWorkItem in modern .NET? [Discussion #4]

JsonSpeedster
Serialization & I/O
MEMBER
Rep: 82
Join Date: Jun 2025
Posts: 7
Thanks: 87
2y ago · May 4, 2024 8:36 PM
#1
Is there any real performance difference between Task.Run and ThreadPool.QueueUserWorkItem in .NET 8, or does Task.Run just wrap it with a Task object?
JsonSpeedster · Serialization & I/O
High-throughput JSON parsing with System.Text.Json, Utf8Json...
The following users thanked JsonSpeedster for this post:
CanvasCrafter
UI & Custom Graphics
MEMBER
Rep: 76
Join Date: Oct 2023
Posts: 6
Thanks: 82
2y ago · May 4, 2024 11:51 PM
#2
Task.Run() uses the ThreadPool internally under the hood! The major advantage of Task.Run is that it returns a Task/Task<T> that supports async/await, cancellation tokens, continuation chaining with ContinueWith, and proper exception propagation. QueueUserWorkItem is lower level and harder to capture exceptions from.
CanvasCrafter · UI & Custom Graphics
Rendering smooth 2D vector shapes, bezier paths, and ImDrawL...
HexEditorDev
Low-Level Hacker
VIP
Rep: 129
Join Date: May 2024
Posts: 6
Thanks: 33
2y ago · May 6, 2024 4:51 AM
#3
Unless you are building an ultra-low-overhead specialized scheduler where the 48-byte Task allocation is unacceptable, always use Task.Run for clean async code.
HexEditorDev · Low-Level Hacker
Inspecting raw byte streams, endianness swapping, and bitwis...