1
在一些了WaitAll的實現我看到下面的代碼C#的IAsyncResult爲WaitAll
IAsyncResult result1 = Method.BeginInvoke(10, MyCallback, null)
IAsyncResult result2 = Method.BeginInvoke(20, MyCallback, null)
WaitHandle[] waitHandles = new WaitHandle[] { result1.AsyncWaitHandle, result2.AsyncWaitHandle};
WaitHandle.WaitAll(waitHandles)
這看起來對嗎?在創建waitHandles數組之前,其中一個調用完成之後有什麼機會?
問候, Dhananjay
原因是var result = del.EndInvoke(ar); – user489686 2011-04-12 11:34:47
EndInvoke也等待異步結果結束,但回調在到達EndInvoke之前可能仍然被調用。 – 2011-04-12 14:02:32