【发布时间】:2011-09-28 18:48:03
【问题描述】:
我需要使用异步委托调用一个函数,当我阅读 AsyncCallback 的教程时,我看到异步回调定义如下:
static void CallbackMethod(IAsyncResult result)
{
// get the delegate that was used to call that
// method
CacheFlusher flusher = (CacheFlusher) result.AsyncState;
// get the return value from that method call
int returnValue = flusher.EndInvoke(result);
Console.WriteLine("The result was " + returnValue);
}
如果我可以从函数中获取返回值作为参考,请告诉我。 eg:= 我的函数格式为
void GetName(int id,ref string Name);
在这里,我通过引用变量获取函数的输出。如果我使用异步委托调用此函数,我如何读取回调函数的输出?
【问题讨论】:
标签: c# .net asynchronous asynccallback