static bool OperationComplete(IAsyncResult result) { OperationAsyncResult thisPtr = (OperationAsyncResult)result.AsyncState; thisPtr.replyMessage = thisPtr.parent.OnEndOperation(result); return(true); }
static bool OpenComplete(IAsyncResult openResult) { OperationAsyncResult thisPtr = (OperationAsyncResult)openResult.AsyncState; try { ((ICommunicationObject)thisPtr.parent).EndOpen(openResult); } finally { Queue <OperationAsyncResult> localWaiters = null; lock (thisPtr.parent.thisLock) { localWaiters = thisPtr.parent.waiters; thisPtr.parent.waiters = null; thisPtr.parent.openCompleted = true; } if (localWaiters != null && localWaiters.Count > 0) { if (signalWaiter == null) { signalWaiter = new Action <object>(SignalWaiter); } //foreach over Queue<T> goes FIFO foreach (OperationAsyncResult waiter in localWaiters) { ActionItem.Schedule(signalWaiter, waiter); } } } return(thisPtr.CallOperation()); }
static void SignalWaiter(object state) { OperationAsyncResult waiter = (OperationAsyncResult)state; try { if (waiter.CallOperation()) { waiter.Complete(false); } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } waiter.Complete(false, exception); } }
public static Message End(IAsyncResult result) { OperationAsyncResult thisPtr = AsyncResult.End <OperationAsyncResult>(result); return(thisPtr.replyMessage); }
public Message EndOperation(IAsyncResult result) { return(OperationAsyncResult.End(result)); }