コード例 #1
0
        //public bool TryReceive(TimeSpan timeout, out RequestContext requestContext)
        //{
        //    return this.channelBinder.TryReceive(timeout, out requestContext);
        //}

        //public IAsyncResult BeginTryReceive(TimeSpan timeout, AsyncCallback callback, object state)
        //{
        //    // At anytime there can be only one thread in BeginTryReceive and the
        //    // outstanding AsyncResult should have completed before the next one.
        //    // There should be no pending oustanding result here.
        //    Fx.AssertAndThrow(this.outstanding == null, "BeginTryReceive should not have a pending result.");

        //    MultipleReceiveAsyncResult multipleReceiveResult = new MultipleReceiveAsyncResult(callback, state);
        //    this.outstanding = multipleReceiveResult;
        //    EnsurePump(timeout);
        //    IAsyncResult innerResult;
        //    if (this.pendingResults.TryDequeueHead(out innerResult))
        //    {
        //        HandleReceiveRequestComplete(innerResult, true);
        //    }

        //    return multipleReceiveResult;
        //}

        //void EnsurePump(TimeSpan timeout)
        //{
        //    // ensure we're running at full throttle, the BeginTryReceive calls we make below on the
        //    // IChannelBinder will typically complete future calls to BeginTryReceive made by CannelHandler
        //    // corollary to that is that most times these calls will be completed sycnhronously
        //    while (!this.pendingResults.IsFull)
        //    {
        //        ReceiveScopeSignalGate receiveScope = new ReceiveScopeSignalGate(this);

        //        // Enqueue the result without locks since this is the pump.
        //        // BeginTryReceive can be called only from one thread and
        //        // the head is not yet unlocked so no items can proceed.
        //        this.pendingResults.Enqueue(receiveScope);
        //        IAsyncResult result = this.channelBinder.BeginTryReceive(timeout, onInnerReceiveCompleted, receiveScope);
        //        if (result.CompletedSynchronously)
        //        {
        //            this.SignalReceiveCompleted(result);
        //        }
        //    }
        //}

        //public bool EndTryReceive(IAsyncResult result, out RequestContext requestContext)
        //{
        //    return MultipleReceiveAsyncResult.End(result, out requestContext);
        //}

        public RequestContext CreateRequestContext(Message message)
        {
            return(channelBinder.CreateRequestContext(message));
        }