public CloseAsyncResult(HttpCookieReplySessionChannelListener listener, TimeSpan timeout,
                                    AsyncCallback callback, object state)
                : base(callback, state)
            {
                lock (listener.channelMapping)
                {
                    // If all the accepted channels have been released, abort the inner channel.
                    if (listener.innerChannel != null && listener.channelMapping.Count == 0)
                    {
                        this.innerChannel = listener.innerChannel;
                    }
                }

                if (this.innerChannel != null)
                {
                    IAsyncResult result = this.innerChannel.BeginClose(
                        timeout, new AsyncCallback(OnInnerChannelClose), null);

                    if (!result.CompletedSynchronously)
                    {
                        return;
                    }

                    this.innerChannel.EndClose(result);
                }

                base.Complete(true);
            }
 public HttpCookieReplySessionChannel(HttpCookieReplySessionChannelListener parent, EndpointAddress localAddress)
     : base(parent)
 {
     this.parent         = parent;
     this.localAddress   = localAddress;
     this.sessionTimeout = parent.SessionTimeout;
     this.session        = new HttpCookieReplySession();
     this.requestQueue   = new InputQueue <RequestContext>();
 }
            public OpenAsyncResult(HttpCookieReplySessionChannelListener parent, TimeSpan timeout,
                                   AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.parent        = parent;
                this.timeoutHelper = new TimeoutHelper(timeout);
                IAsyncResult result = parent.innerChannelListener.BeginOpen(timeoutHelper.RemainingTime(),
                                                                            new AsyncCallback(OnInnerChannelListenerOpen), null);

                if (!result.CompletedSynchronously)
                {
                    return;
                }

                if (OnInnerChannelListenerOpenCore(result))
                {
                    base.Complete(true);
                }
            }