开发者

Thread.Start() vs BackgroundWorker

开发者 https://www.devze.com 2022-12-14 16:06 出处:网络
what is the difference between cre开发者_开发技巧ate thread using thread.start and using background worker ?Assuming you are talking about .NET a BackgroundWorker uses a thread from the thread pool (i

what is the difference between cre开发者_开发技巧ate thread using thread.start and using background worker ?


Assuming you are talking about .NET a BackgroundWorker uses a thread from the thread pool (it doesn't create a new thread but it might block if there are no threads available in the pool) while Thread.Start starts a new managed thread.


A background worker uses a thread from the thread pool. Thread pool threads are regular threads but as they are reused the cost of starting them is amortized. As the cost of starting a thread may be significant the thread pool is ideal for short running tasks.


the big advantage of BackgroundWorker is that you can call GUI code in it's ProgressChanged event handler.

0

精彩评论

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