BackgroundWorker中的同步工作 [英] Synchronous work in a BackgroundWorker

查看:166
本文介绍了BackgroundWorker中的同步工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序对多个文件独立执行耗时的工作.我创建了BackgroundWorker来将工作传递给每个文件,但是看来backgroundworker仅能够执行异步工作.是否可以同时执行多个异步任务,或者是否存在类似的对象来执行同步操作?

My application performs time consuming work independently on several files. I created a BackgroundWorker to pass the work off to on each file, but it appears the backgroundworker is only capable of performing asynchronous work. Is it possible to do several asynchronous tasks in unison with it, or is there a similar object for performing synchronous operations?

推荐答案

后台工作人员通常用于更新UI和/或通过工作,以便在长时间运行的过程中不会冻结UI.这意味着您让"后台工作程序传递"了文件工作",然后使用回调(通常)来更新UI,在此期间您的APP始终保持响应状态.

The background worker is usually used to update the UI and/or to pass off work so you don't freeze the UI when a long running process takes place. This means that you "pass" the background worker process the "file work" and then use a callback to update the UI(usually) all during which your APP remains responsive.

如果项目是独立的,则可能需要假脱机处理几个线程来拆分工作.再说一次,如果我理解正确的话.如果是,那么您可能要看 Jon Skeet的线程文章.

If the items are independent then you might want to spool up a few threads to split the work. Again, if I am understanding you correctly. If I am then you might want to look at Jon Skeet's threading article.

这篇关于BackgroundWorker中的同步工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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