开发者

In .NET 4, does BeginInvoke and Task use the same threadpool?

开发者 https://www.devze.com 2023-02-16 06:08 出处:网络
.NET 4 introduced a brand new thread pool design accesse开发者_运维知识库d by the Task Parallel library. But if I have old code that uses Delegate.BeginInvoke, will those be executed by that new threa

.NET 4 introduced a brand new thread pool design accesse开发者_运维知识库d by the Task Parallel library. But if I have old code that uses Delegate.BeginInvoke, will those be executed by that new thread pool? Or is the old thread pool still in the runtime somewhere?


They both use the same ThreadPool. ThreadPool.QueueUserWorkItem does, as well.

However, Delegate.BeginInvoke has extra overhead when compared to Task.Factory.StartNew, and does not take advantages of many of the features in the ThreadPool, such as work stealing or the new debugging features. I would recommend refactoring this to use the new Task features as time permits.

0

精彩评论

暂无评论...
验证码 换一张
取 消