AsyncDelete和EndInvoke的疑惑
MyCallback方法是AsyncCallBack的目标方法,我的疑惑是MyCallback的参数IAsyncResult ar是个什么样的参数,它又有什么用?就是在MyCallback里为什么能够用EndInvoke方法,还没有调用BeginInvoke啊??
public static void MyCallback(IAsyncResult ar)
{
int value = Convert.ToInt32(ar.AsyncState);
AsyncResult aResult = (AsyncResult)ar;
SampSyncSqrDelegate temp = (SampSyncSqrDelegate)aResult.AsyncDelegate;
int result = temp.EndInvoke(ar);??
Console.Write( "Simple.SomeMethod (AsyncCallback): Result of ");
Console.WriteLine( "{0} in SampleSynchronized.Square is {1} ", value, result);
}
我在线看着呢,高手回答完后请不要马上离开哦。
------解决方案--------------------ar对应的就是BeginInvode返回的那个IAsyncResult 对象。