void WriteStreamedMessage(TimeSpan timeout) { this.outputStream = GetWrappedOutputStream(); // Since HTTP streams don't support timeouts, we can't just use TimeoutStream here. // Rather, we need to run a timer to bound the overall operation if (onStreamSendTimeout == null) { onStreamSendTimeout = new Action<object>(OnStreamSendTimeout); } IOThreadTimer sendTimer = new IOThreadTimer(onStreamSendTimeout, this, true); sendTimer.Set(timeout); try { MtomMessageEncoder mtomMessageEncoder = messageEncoder as MtomMessageEncoder; if (mtomMessageEncoder == null) { messageEncoder.WriteMessage(this.message, this.outputStream); } else { mtomMessageEncoder.WriteMessage(this.message, this.outputStream, this.mtomBoundary); } } finally { sendTimer.Cancel(); } }
private void CancelSendTimer() { IOThreadTimer sendTimer = this.sendTimer; this.sendTimer = null; if (sendTimer != null) { sendTimer.Cancel(); } }
private void WriteStreamedMessage(TimeSpan timeout) { this.outputStream = this.supportsConcurrentIO ? ((Stream) new BufferedOutputAsyncStream(this.outputStream, 0x4000, 4)) : ((Stream) new BufferedStream(this.outputStream, 0x8000)); if (onStreamSendTimeout == null) { onStreamSendTimeout = new Action<object>(HttpOutput.OnStreamSendTimeout); } IOThreadTimer timer = new IOThreadTimer(onStreamSendTimeout, this, true); timer.Set(timeout); try { MtomMessageEncoder messageEncoder = this.messageEncoder as MtomMessageEncoder; if (messageEncoder == null) { this.messageEncoder.WriteMessage(this.message, this.outputStream); } else { messageEncoder.WriteMessage(this.message, this.outputStream, this.mtomBoundary); } } finally { timer.Cancel(); } }
private void CancelReceiveTimer() { IOThreadTimer receiveTimer = this.receiveTimer; this.receiveTimer = null; if (receiveTimer != null) { receiveTimer.Cancel(); } }