【发布时间】:2010-03-10 15:27:56
【问题描述】:
我有 2 个函数需要一个接一个地执行。在此函数中,进行异步调用。异步调用完成后如何执行第二个函数?
例如。
public void main()
{
executeFn("1");
executeFn("2"); //I want this to be executed after 1 has finished.
}
private bool executeFn(string someval)
{
runSomeAsyncCode(); //This is some async uploading function that is yet to be defined.
}
【问题讨论】:
-
您是在编写 runSomeAsyncCode 方法,还是来自第三方?
-
" 2 个函数需要一个接一个地执行" - 那不就是顺序执行吗?
-
executeFn 中的代码是线程化的,所以我需要将调用放入队列中,以便它们成为连续的。
-
在第一次调用的异步回调中调用 executeFn("2")。
-
@SnOrfus,我们不能。当某些事件发生时,还有其他代码调用 executeFn。
标签: c# silverlight