3
當我異步調用方法(使用BeginXxx/EndXxx模式)時,調用BeginXxx後得到IAsyncResult
結果。如果方法BeginXxxx或EndXxx對結果變量沒有任何引用,那麼屬性「isCompleted」(在返回結果變量中)如何得到更新?如何更新IAsyncResult的屬性isCompleted?
例如:
// Create the delegate.
AsyncMethodCaller caller = new AsyncMethodCaller(ad.TestMethod);
// Initiate the asychronous call.
IAsyncResult result = caller.BeginInvoke(3000, out threadId, null, null);
// Poll while simulating work.
while(result.IsCompleted == false) {
Thread.Sleep(250);
Console.Write(".");
}
確定。這說得通。所以這個引用是通過XxxxEnd傳遞的,它將isCompleted屬性更改爲false。謝謝... – outlookrperson 2012-03-08 14:06:09