コード例 #1
0
                static bool OperationComplete(IAsyncResult result)
                {
                    OperationAsyncResult thisPtr = (OperationAsyncResult)result.AsyncState;

                    thisPtr.replyMessage = thisPtr.parent.OnEndOperation(result);
                    return(true);
                }
コード例 #2
0
                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());
                }
コード例 #3
0
                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);
                    }
                }
コード例 #4
0
                public static Message End(IAsyncResult result)
                {
                    OperationAsyncResult thisPtr = AsyncResult.End <OperationAsyncResult>(result);

                    return(thisPtr.replyMessage);
                }
コード例 #5
0
 public Message EndOperation(IAsyncResult result)
 {
     return(OperationAsyncResult.End(result));
 }