geo*_*eek 2 .net c# multithreading backgroundworker
我有一系列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
Run Code Online (Sandbox Code Playgroud)
我想用背景工作者做这个,但功能是异步的.
请帮忙
Phi*_*idt 10
为什么不在同一个后台工作程序中按顺序执行所有这三个?因此,您的backgroundworker工作事件将如下所示:
private void yourBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
open_session();
open_session();
close_session();
}
Run Code Online (Sandbox Code Playgroud)
这样,后台工作程序本身就是异步的,但是您希望按顺序运行的三种方法仍然在异步方法的上下文中按顺序运行.