简体   繁体   中英

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

.NET 4 introduced a brand new thread pool design accessed 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM