TaskFactory.StartNew versus ThreadPool.QueueUserWorkItem
Posted
by Dan Tao
on Stack Overflow
See other posts from Stack Overflow
or by Dan Tao
Published on 2010-06-15T16:50:00Z
Indexed on
2010/06/15
16:52 UTC
Read the original article
Hit count: 995
Apparently the TaskFactory.StartNew
method in .NET 4.0 is intended as a replacement for ThreadPool.QueueUserWorkItem
(according to this post, anyway). My question is simple: does anyone know why?
Does TaskFactory.StartNew
have better performance? Does it use less memory? Or is it mainly for the additional functionality provided by the Task
class? In the latter case, does StartNew
possibly have worse performance than QueueUserWorkItem
?
It seems to me that StartNew
would actually potentially use more memory than QueueUserWorkItem
, since it returns a Task
object with every call and I would expect that to result in more memory allocation.
In any case, I'm interested to know which is more appropriate for a high-performance scenario.
© Stack Overflow or respective owner