我有一个函数,我在c#.net中使用了一个线程.
我在该线程的下一行有另一个函数.但是只有在线程执行后才能调用此函数.
我该怎么做 ?
例..
Somefunction()
{
// thread //(thread started)
add() (another function but need to be executed only tha above thread gets over)
}
Run Code Online (Sandbox Code Playgroud)
使用BackgroundWorker并在worker completeted事件处理程序中包含函数调用.
var worker = new BackgroundWorker();
_worker.DoWork += delegate { DoStuff(); };
_worker.RunWorkerCompleted += worker_RunWorkerCompleted;
_worker.RunWorkerAsync();
[...]
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
/// Do post-thread stuff
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3218 次 |
| 最近记录: |