我有一个3个耗时函数的序列,我想在后台工作者或其他任何工具中执行它们,我的问题是每个函数都应该等待先验函数完成,所以这是我的伪代码:链中的多背景工作者
open_session() // during the execution of this function i like to display a loading-window
open_session() //this function opens a process another windows app , while opening this app i would like to keep the current app responsive.
close_session()// during the execution of this function i like to display a loading-window
我想象使用后台工作者来做到这一点,但功能是异步的。
任何帮助,请
为什么还要花费管理所有这些额外的线程/任务的开销,如果你只是想同步它们。首先,最好只使用一个BGW。 – Servy 2012-08-10 21:09:30
@Servy是什么类型的开销呢,真的吗?它可能会使代码更具可读性,例如,如果使用'e.Result',并且每个任务完成后分配的结果是不同的类型。我已经看到代码将所有异步的东西加入到一个大的DoWork事件处理器中;可能没有经历管理额外线程的开销,但是膨胀并且更难以调试。 – 2012-08-10 21:53:23
是啊我正在寻找你的解决方案,但我试图避免玩BGW RunWorkerCompleted事件,有没有办法避免玩这个事件? – geogeek 2012-08-10 22:23:17