如果BackgroundWorker控件被大量使用怎么办? [英] What if BackgroundWorker control used massively?

查看:68
本文介绍了如果BackgroundWorker控件被大量使用怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很担心C#程序中大量使用BackgroundWorker控件会使程序变慢且责任心很弱.因此,请告诉我是否大量使用BackgroundWorker控件是否存在此类问题?

I''m being afraid if a mass usage of BackgroundWorker control in a C# program will make the program slow and poorly responsible. So tell me if there is any such or any other problem if BackgroundWorker control used massively?

推荐答案

我相信BackgroundWorkers(和.Net 4任务)使用了线程池,并将适当地使用线程.当然,如果您尝试一次执行太多操作,则程序会变慢–没错,但是您将工作分散了.但是我认为BackgroundWorkers不会给您带来大量的开销问题.
I believe that BackgroundWorkers (and .Net 4 Tasks) use a thread pool, and will make appropriate use of threads. Of course, if you''re trying to do too much at once the program will become slow – that''s true however you divide up the work. But I don''t think BackgroundWorkers will give you massive overhead problems.


后台工作人员会对性能产生不良影响的主要原因是后台进程与后台工作人员之间的沟通过多.主线程(例如,过于频繁地调用ReportProgress或过多地锁定对象).
The main reason a background worker would have a bad effect on performance would be too much communication between the background process and the main thread (for ex. calling ReportProgress too often or locking objects too much).


这篇关于如果BackgroundWorker控件被大量使用怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆