public void SendRequest(Message message, TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); try { this.connection = this.connectionPoolHelper.EstablishConnection(timeoutHelper.RemainingTime()); ChannelBindingUtility.TryAddToMessage(this.channel.channelBindingToken, message, false); bool flag = false; try { StreamingConnectionHelper.WriteMessage(message, this.connection, true, this.channel.settings, ref timeoutHelper); flag = true; } finally { if (!flag) { this.connectionPoolHelper.Abort(); } } } catch (TimeoutException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException(System.ServiceModel.SR.GetString("TimeoutOnRequest", new object[] { timeout }), exception)); } }
public async Task SendRequestAsync(Message message, TimeoutHelper timeoutHelper) { _timeoutHelper = timeoutHelper; _message = message; bool success = false; try { try { _connection = await _connectionPoolHelper.EstablishConnectionAsync(timeoutHelper.RemainingTime()); ChannelBindingUtility.TryAddToMessage(_channel._channelBindingToken, _message, false); await StreamingConnectionHelper.WriteMessageAsync(_message, _connection, true, _channel._settings, timeoutHelper); } catch (TimeoutException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new TimeoutException(SR.Format(SR.TimeoutOnRequest, timeoutHelper.RemainingTime()), exception)); } success = true; } finally { if (!success) { Cleanup(); } } }
public void SendRequest(Message message, TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); try { this.connection = connectionPoolHelper.EstablishConnection(timeoutHelper.RemainingTime()); ChannelBindingUtility.TryAddToMessage(this.channel.channelBindingToken, message, false); bool success = false; try { StreamingConnectionHelper.WriteMessage(message, this.connection, true, channel.settings, ref timeoutHelper); success = true; } finally { if (!success) { connectionPoolHelper.Abort(); } } } catch (TimeoutException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new TimeoutException(SR.GetString(SR.TimeoutOnRequest, timeout), exception)); } }
private bool HandleEstablishConnection(IAsyncResult result) { this.connection = this.connectionPoolHelper.EndEstablishConnection(result); ChannelBindingUtility.TryAddToMessage(this.channel.channelBindingToken, this.message, false); IAsyncResult result2 = StreamingConnectionHelper.BeginWriteMessage(this.message, this.connection, true, this.channel.settings, ref this.timeoutHelper, onWriteMessage, this); if (!result2.CompletedSynchronously) { return(false); } return(this.HandleWriteMessage(result2)); }
private bool HandleWriteMessage(IAsyncResult result) { StreamingConnectionHelper.EndWriteMessage(result); this.connectionReader = new StreamedFramingRequestChannel.ClientSingletonConnectionReader(this.connection, this.connectionPoolHelper, this.channel.settings); this.connectionReader.DoneSending(TimeSpan.Zero); IAsyncResult result2 = this.connectionReader.BeginReceive(this.timeoutHelper.RemainingTime(), onReceiveReply, this); if (!result2.CompletedSynchronously) { return(false); } return(this.CompleteReceiveReply(result2)); }
bool HandleWriteMessage(IAsyncResult result) { // write out the streamed message StreamingConnectionHelper.EndWriteMessage(result); connectionReader = new ClientSingletonConnectionReader(connection, connectionPoolHelper, channel.settings); connectionReader.DoneSending(TimeSpan.Zero); // we still need to receive IAsyncResult receiveResult = connectionReader.BeginReceive(timeoutHelper.RemainingTime(), onReceiveReply, this); if (!receiveResult.CompletedSynchronously) { return(false); } return(CompleteReceiveReply(receiveResult)); }
protected override void OnReply(Message message, TimeSpan timeout) { this.timeoutHelper = new TimeoutHelper(timeout); StreamingConnectionHelper.WriteMessage(message, this.connection, false, this.settings, ref this.timeoutHelper); this.parent.DoneSending(this.timeoutHelper.RemainingTime()); }
protected override void OnEndReply(IAsyncResult result) { StreamingConnectionHelper.EndWriteMessage(result); this.parent.DoneSending(this.timeoutHelper.RemainingTime()); }
protected override IAsyncResult OnBeginReply(Message message, TimeSpan timeout, AsyncCallback callback, object state) { this.timeoutHelper = new TimeoutHelper(timeout); return(StreamingConnectionHelper.BeginWriteMessage(message, this.connection, false, this.settings, ref this.timeoutHelper, callback, state)); }