private void SetWriteTimeOut(TimeSpan timeout, bool synchronous)
 {
     if (!synchronous)
     {
         this.SendTimeout = timeout;
         if (timeout == TimeSpan.MaxValue)
         {
             this.CancelSendTimer();
             return;
         }
         this.SendTimer.Set(timeout);
     }
     else
     {
         this.CancelSendTimer();
         if (timeout <= TimeSpan.Zero)
         {
             ExceptionTrace exception             = Fx.Exception;
             string         tcpConnectionTimedOut = Resources.TcpConnectionTimedOut;
             object[]       objArray = new object[] { timeout };
             throw exception.AsInformation(new TimeoutException(Microsoft.ServiceBus.SR.GetString(tcpConnectionTimedOut, objArray)), null);
         }
         if (BaseStreamConnection.UpdateTimeout(this.SendTimeout, timeout))
         {
             lock (this.ThisLock)
             {
                 this.ThrowIfClosed();
             }
             this.SendTimeout = timeout;
             return;
         }
     }
 }