protected override IEnumerator <IteratorAsyncResult <SharedChannel <TChannel> .CreateChannelAsyncResult> .AsyncStep> GetAsyncSteps() { ServiceBusUriManager serviceBusUriManager = new ServiceBusUriManager(this.sharedChannel.viaAddresses.ToList <Uri>(), false); while (true) { if (serviceBusUriManager.MoveNextUri()) { this.Channel = this.sharedChannel.innerFactory.CreateChannel(new EndpointAddress(serviceBusUriManager.Current, new AddressHeader[0]), serviceBusUriManager.Current); SharedChannel <TChannel> .CreateChannelAsyncResult createChannelAsyncResult = this; IteratorAsyncResult <SharedChannel <TChannel> .CreateChannelAsyncResult> .BeginCall beginCall = (SharedChannel <TChannel> .CreateChannelAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.Channel.BeginOpen(t, c, s); yield return(createChannelAsyncResult.CallAsync(beginCall, (SharedChannel <TChannel> .CreateChannelAsyncResult thisPtr, IAsyncResult r) => thisPtr.Channel.EndOpen(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { break; } this.Channel.Abort(); } else { if (base.LastAsyncStepException == null) { break; } if (!(base.LastAsyncStepException is TimeoutException)) { throw base.LastAsyncStepException; } throw new CommunicationException(SRClient.OpenChannelFailed(base.OriginalTimeout), base.LastAsyncStepException); } } }
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 <SharedChannel <TChannel> .CloseOrAbortAsyncResult> .AsyncStep> GetAsyncSteps() { if (this.channel != null) { if (!this.abort) { SharedChannel <TChannel> .CloseOrAbortAsyncResult closeOrAbortAsyncResult = this; IteratorAsyncResult <SharedChannel <TChannel> .CloseOrAbortAsyncResult> .BeginCall beginCall = (SharedChannel <TChannel> .CloseOrAbortAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.channel.BeginClose(t, c, s); IteratorAsyncResult <SharedChannel <TChannel> .CloseOrAbortAsyncResult> .EndCall endCall = (SharedChannel <TChannel> .CloseOrAbortAsyncResult thisPtr, IAsyncResult r) => thisPtr.channel.EndClose(r); yield return(closeOrAbortAsyncResult.CallAsync(beginCall, endCall, (SharedChannel <TChannel> .CloseOrAbortAsyncResult thisPtr, TimeSpan t) => thisPtr.channel.Close(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer)); } else { this.channel.Abort(); } } }
public CreateChannelAsyncResult(SharedChannel <TChannel> sharedChannel, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.sharedChannel = sharedChannel; }
public CloseOrAbortAsyncResult(SharedChannel <TChannel> sharedChannel, bool abort, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.abort = abort; sharedChannel.Invalidate(out this.channel); }