public RequestSessionChannel(ReconnectBindingElement.ReconnectChannelFactory <IRequestSessionChannel> factory, EndpointAddress address, IEnumerable <Uri> viaAddresses) : base(factory) { this.innerFactory = factory.innerFactory; this.RemoteAddress = address; this.Via = viaAddresses.First <Uri>(); ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.OutputSession outputSession = new ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.OutputSession() { Id = Guid.NewGuid().ToString() }; this.Session = outputSession; this.sharedChannel = new SharedChannel <IRequestSessionChannel>(this.innerFactory, viaAddresses); }
protected override IEnumerator <IteratorAsyncResult <ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult> .AsyncStep> GetAsyncSteps() { int num = 0; TimeSpan timeSpan = base.RemainingTime(); while (true) { if (timeSpan <= TimeSpan.Zero) { TimeSpan originalTimeout = base.OriginalTimeout; throw new TimeoutException(SRClient.OperationRequestTimedOut(originalTimeout.TotalMilliseconds)); } ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult requestAsyncResult = this; IteratorAsyncResult <ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult> .BeginCall beginCall = (ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.requestSessionChannel.sharedChannel.BeginGetInstance(timeSpan, c, s); yield return(requestAsyncResult.CallAsync(beginCall, (ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => thisPtr.innerChannel = thisPtr.requestSessionChannel.sharedChannel.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer)); ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult requestAsyncResult1 = this; IteratorAsyncResult <ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult> .BeginCall beginCall1 = (ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.innerChannel.BeginRequest(thisPtr.message, timeSpan, c, s); IteratorAsyncResult <ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult> .EndCall responseMessage = (ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => thisPtr.ResponseMessage = thisPtr.innerChannel.EndRequest(r); yield return(requestAsyncResult1.CallAsync(beginCall1, responseMessage, (ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.RequestAsyncResult thisPtr, TimeSpan t) => thisPtr.ResponseMessage = thisPtr.innerChannel.Request(thisPtr.message, t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); Exception lastAsyncStepException = base.LastAsyncStepException; if (lastAsyncStepException == null) { break; } if (!ReconnectBindingElement.IsRetryable(this.message, lastAsyncStepException)) { base.Complete(lastAsyncStepException); break; } else if (num >= 1 || this.requestSessionChannel.State != CommunicationState.Opened) { if (this.message != null) { this.message.SafeClose(); } base.Complete(lastAsyncStepException); break; } else { num++; MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteRetryOperation("SharedChannel.Request", num, lastAsyncStepException.Message)); yield return(base.CallAsyncSleep(TimeSpan.FromMilliseconds(500))); timeSpan = base.RemainingTime(); } } }
public RequestAsyncResult(ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel requestSessionChannel, Message message, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.requestSessionChannel = requestSessionChannel; this.message = message; }