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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

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

ImGuiFanatic
Graphics & ImGui
MEMBER
Rep: 159
Join Date: Aug 2021
Posts: 6
Thanks: 35
5y ago · Aug 4, 2021 6:03 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?
ImGuiFanatic · Graphics & ImGui
Dear ImGui is the best GUI library ever made. Change my mind...
The following users thanked ImGuiFanatic for this post:
BytePusher
Memory & Performance
MEMBER
Rep: 209
Join Date: Dec 2025
Posts: 13
Thanks: 32
5y ago · Aug 4, 2021 7:23 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.
BytePusher · Memory & Performance
Zero-allocation C# code using Span<T>, Memory<T>, and Unsafe...
LinQ_Lover
C# Developer
MEMBER
Rep: 313
Join Date: Jul 2020
Posts: 8
Thanks: 27
5y ago · Aug 4, 2021 10:23 PM
#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.
LinQ_Lover · C# Developer
Clean code, fluent LINQ expressions, and expressive C# patte...