public CloseReplySessionChannelAsyncResult(ReliableChannelBinder <IReplySessionChannel> binder, IReplySessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state) : base(binder, channel, timeout, callback, state)
 {
     if (base.Begin())
     {
         base.Complete(true);
     }
 }
コード例 #2
0
 protected CloseInputSessionChannelAsyncResult(ReliableChannelBinder <TChannel> binder, TChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.binder        = binder;
     this.channel       = channel;
     this.timeoutHelper = new TimeoutHelper(timeout);
 }
        internal static void CloseReplySessionChannel(ReliableChannelBinder <IReplySessionChannel> binder, IReplySessionChannel channel, TimeSpan timeout)
        {
            RequestContext context;
            TimeoutHelper  helper = new TimeoutHelper(timeout);

            binder.WaitForPendingOperations(helper.RemainingTime());
            TimeSpan span = helper.RemainingTime();
            bool     flag = span == TimeSpan.Zero;

Label_0029:
            context = null;
            bool flag2 = true;

            try
            {
                bool flag3 = channel.TryReceiveRequest(span, out context);
                flag2 = false;
                if (flag3 && (context == null))
                {
                    channel.Close(helper.RemainingTime());
                    return;
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                if (!flag2)
                {
                    throw;
                }
                if (!MaskHandled(binder.DefaultMaskingMode) || !binder.IsHandleable(exception))
                {
                    throw;
                }
                flag2 = false;
            }
            finally
            {
                if (context != null)
                {
                    context.RequestMessage.Close();
                    context.Close();
                }
                if (flag2)
                {
                    channel.Abort();
                }
            }
            if (!flag && (channel.State == CommunicationState.Opened))
            {
                span = helper.RemainingTime();
                flag = span == TimeSpan.Zero;
                goto Label_0029;
            }
            channel.Abort();
        }
        internal static void CloseDuplexSessionChannel(ReliableChannelBinder <IDuplexSessionChannel> binder, IDuplexSessionChannel channel, TimeSpan timeout)
        {
            Message       message;
            TimeoutHelper helper = new TimeoutHelper(timeout);

            channel.Session.CloseOutputSession(helper.RemainingTime());
            binder.WaitForPendingOperations(helper.RemainingTime());
            TimeSpan span = helper.RemainingTime();
            bool     flag = span == TimeSpan.Zero;

Label_003B:
            message = null;
            bool flag2 = true;

            try
            {
                bool flag3 = channel.TryReceive(span, out message);
                flag2 = false;
                if (flag3 && (message == null))
                {
                    channel.Close(helper.RemainingTime());
                    return;
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                if (!flag2)
                {
                    throw;
                }
                if (!MaskHandled(binder.DefaultMaskingMode) || !binder.IsHandleable(exception))
                {
                    throw;
                }
                flag2 = false;
            }
            finally
            {
                if (message != null)
                {
                    message.Close();
                }
                if (flag2)
                {
                    channel.Abort();
                }
            }
            if (!flag && (channel.State == CommunicationState.Opened))
            {
                span = helper.RemainingTime();
                flag = span == TimeSpan.Zero;
                goto Label_003B;
            }
            channel.Abort();
        }
            public CloseDuplexSessionChannelAsyncResult(ReliableChannelBinder <IDuplexSessionChannel> binder, IDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state) : base(binder, channel, timeout, callback, state)
            {
                bool         flag   = false;
                IAsyncResult result = base.Channel.Session.BeginCloseOutputSession(base.RemainingTime, onCloseOutputSessionCompleteStatic, this);

                if (result.CompletedSynchronously)
                {
                    flag = this.HandleCloseOutputSessionComplete(result);
                }
                if (flag)
                {
                    base.Complete(true);
                }
            }
コード例 #6
0
        internal static void CloseReplySessionChannel(ReliableChannelBinder <IReplySessionChannel> binder, IReplySessionChannel channel, TimeSpan timeout)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

            binder.WaitForPendingOperations(timeoutHelper.RemainingTime());
            TimeSpan timeout1 = timeoutHelper.RemainingTime();
            bool     flag1    = timeout1 == TimeSpan.Zero;

            while (true)
            {
                RequestContext context = (RequestContext)null;
                bool           flag2   = true;
                try
                {
                    bool request = channel.TryReceiveRequest(timeout1, out context);
                    flag2 = false;
                    if (request)
                    {
                        if (context == null)
                        {
                            channel.Close(timeoutHelper.RemainingTime());
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (Fx.IsFatal(ex))
                    {
                        throw;
                    }
                    else if (flag2)
                    {
                        if (!ReliableChannelBinderHelper.MaskHandled(binder.DefaultMaskingMode) || !binder.IsHandleable(ex))
                        {
                            throw;
                        }
                        else
                        {
                            flag2 = false;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
                finally
                {
                    if (context != null)
                    {
                        context.RequestMessage.Close();
                        context.Close();
                    }
                    if (flag2)
                    {
                        channel.Abort();
                    }
                }
                if (!flag1 && channel.State == CommunicationState.Opened)
                {
                    timeout1 = timeoutHelper.RemainingTime();
                    flag1    = timeout1 == TimeSpan.Zero;
                }
                else
                {
                    break;
                }
            }
            channel.Abort();
        }
コード例 #7
0
        internal static void CloseDuplexSessionChannel(ReliableChannelBinder <IDuplexSessionChannel> binder, IDuplexSessionChannel channel, TimeSpan timeout)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

            channel.Session.CloseOutputSession(timeoutHelper.RemainingTime());
            binder.WaitForPendingOperations(timeoutHelper.RemainingTime());
            TimeSpan timeout1 = timeoutHelper.RemainingTime();
            bool     flag1    = timeout1 == TimeSpan.Zero;

            while (true)
            {
                Message message = (Message)null;
                bool    flag2   = true;
                try
                {
                    bool flag3 = channel.TryReceive(timeout1, out message);
                    flag2 = false;
                    if (flag3)
                    {
                        if (message == null)
                        {
                            channel.Close(timeoutHelper.RemainingTime());
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (Fx.IsFatal(ex))
                    {
                        throw;
                    }
                    else if (flag2)
                    {
                        if (!ReliableChannelBinderHelper.MaskHandled(binder.DefaultMaskingMode) || !binder.IsHandleable(ex))
                        {
                            throw;
                        }
                        else
                        {
                            flag2 = false;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
                finally
                {
                    if (message != null)
                    {
                        message.Close();
                    }
                    if (flag2)
                    {
                        channel.Abort();
                    }
                }
                if (!flag1 && channel.State == CommunicationState.Opened)
                {
                    timeout1 = timeoutHelper.RemainingTime();
                    flag1    = timeout1 == TimeSpan.Zero;
                }
                else
                {
                    break;
                }
            }
            channel.Abort();
        }
コード例 #8
0
 internal static IAsyncResult BeginCloseReplySessionChannel(ReliableChannelBinder <IReplySessionChannel> binder, IReplySessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return((IAsyncResult) new ReliableChannelBinderHelper.CloseReplySessionChannelAsyncResult(binder, channel, timeout, callback, state));
 }
 internal static IAsyncResult BeginCloseDuplexSessionChannel(ReliableChannelBinder <IDuplexSessionChannel> binder, IDuplexSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(new CloseDuplexSessionChannelAsyncResult(binder, channel, timeout, callback, state));
 }