示例#1
0
            private static void WaitOverCallback(object state, Exception asyncException)
            {
                SessionChannelDemuxer <TInnerChannel, TInnerItem> .OpenAsyncResult result = (SessionChannelDemuxer <TInnerChannel, TInnerItem> .OpenAsyncResult)state;
                bool      flag      = false;
                Exception exception = asyncException;

                if (exception != null)
                {
                    flag = true;
                }
                else
                {
                    try
                    {
                        flag = result.OnWaitOver();
                    }
                    catch (Exception exception2)
                    {
                        if (Fx.IsFatal(exception2))
                        {
                            throw;
                        }
                        flag      = true;
                        exception = exception2;
                    }
                }
                if (flag)
                {
                    result.Cleanup();
                    result.Complete(false, exception);
                }
            }
示例#2
0
 public OpenAsyncResult(SessionChannelDemuxer <TInnerChannel, TInnerItem> channelDemuxer, ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.channelDemuxer = channelDemuxer;
     this.filter         = filter;
     this.listener       = listener;
     this.timeoutHelper  = new TimeoutHelper(timeout);
     if (this.channelDemuxer.openSemaphore.EnterAsync(this.timeoutHelper.RemainingTime(), SessionChannelDemuxer <TInnerChannel, TInnerItem> .OpenAsyncResult.waitOverCallback, this))
     {
         bool flag  = false;
         bool flag2 = false;
         try
         {
             flag2 = this.OnWaitOver();
             flag  = true;
         }
         finally
         {
             if (!flag)
             {
                 this.Cleanup();
             }
         }
         if (flag2)
         {
             this.Cleanup();
             base.Complete(true);
         }
     }
 }
示例#3
0
            public PeekAsyncResult(SessionChannelDemuxer <TInnerChannel, TInnerItem> demuxer, TInnerChannel channel, AsyncCallback callback, object state) : base(callback, state)
            {
                this.demuxer = demuxer;
                this.channel = channel;
                IAsyncResult result = this.channel.BeginOpen(SessionChannelDemuxer <TInnerChannel, TInnerItem> .PeekAsyncResult.onOpenComplete, this);

                if (result.CompletedSynchronously && this.HandleOpenComplete(result))
                {
                    base.Complete(true);
                }
            }
示例#4
0
 private static void OnPeekCompleteStatic(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         SessionChannelDemuxer <TInnerChannel, TInnerItem> asyncState = (SessionChannelDemuxer <TInnerChannel, TInnerItem>)result.AsyncState;
         bool flag = true;
         try
         {
             asyncState.HandlePeekResult(result);
             flag = false;
         }
         catch (CommunicationException exception)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
             }
         }
         catch (ObjectDisposedException exception2)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
             }
         }
         catch (Exception exception3)
         {
             if (Fx.IsFatal(exception3))
             {
                 throw;
             }
             asyncState.HandleUnknownException(exception3);
             flag = false;
         }
         finally
         {
             if (flag)
             {
                 asyncState.throttle.Release();
             }
         }
     }
 }
示例#5
0
 private static void OpenListenerCallback(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         SessionChannelDemuxer <TInnerChannel, TInnerItem> .OpenAsyncResult asyncState = (SessionChannelDemuxer <TInnerChannel, TInnerItem> .OpenAsyncResult)result.AsyncState;
         Exception exception = null;
         try
         {
             asyncState.OnEndInnerListenerOpen(result);
         }
         catch (Exception exception2)
         {
             if (Fx.IsFatal(exception2))
             {
                 throw;
             }
             exception = exception2;
         }
         if (exception != null)
         {
             asyncState.channelDemuxer.pendingExceptionOnOpen = exception;
         }
         asyncState.Cleanup();
         asyncState.Complete(false, exception);
     }
 }
示例#6
0
 private static void OnReceiveCompleteStatic(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         SessionChannelDemuxer <TInnerChannel, TInnerItem> .PeekAsyncResult asyncState = (SessionChannelDemuxer <TInnerChannel, TInnerItem> .PeekAsyncResult)result.AsyncState;
         Exception exception = null;
         try
         {
             asyncState.HandleReceiveComplete(result);
         }
         catch (Exception exception2)
         {
             if (Fx.IsFatal(exception2))
             {
                 throw;
             }
             exception = exception2;
         }
         asyncState.Complete(false, exception);
     }
 }
示例#7
0
 private static void OnOpenCompleteStatic(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         SessionChannelDemuxer <TInnerChannel, TInnerItem> .PeekAsyncResult asyncState = (SessionChannelDemuxer <TInnerChannel, TInnerItem> .PeekAsyncResult)result.AsyncState;
         bool      flag      = false;
         Exception exception = null;
         try
         {
             flag = asyncState.HandleOpenComplete(result);
         }
         catch (Exception exception2)
         {
             if (Fx.IsFatal(exception2))
             {
                 throw;
             }
             exception = exception2;
             flag      = true;
         }
         if (flag)
         {
             asyncState.Complete(false, exception);
         }
     }
 }
示例#8
0
 public static void End(IAsyncResult result, out TInnerChannel channel, out TInnerItem item)
 {
     SessionChannelDemuxer <TInnerChannel, TInnerItem> .PeekAsyncResult result2 = AsyncResult.End <SessionChannelDemuxer <TInnerChannel, TInnerItem> .PeekAsyncResult>(result);
     channel = result2.channel;
     item    = result2.item;
 }