private void StopTimer() { if (_timeout == System.Threading.Timeout.Infinite) { return; } _stopwatch.Stop(); if (_stopwatch.ElapsedMilliseconds > _timeout) { ResetTimeout(System.Threading.Timeout.Infinite); throw new TimeoutException("Timeout in IO operation"); } }
private void StopTimer() { if (_timeout == System.Threading.Timeout.Infinite) { return; } _stopwatch.Stop(); // Normally, a timeout exception would be thrown by stream itself, // since we set the read/write timeout for the stream. However // there is a gap between end of IO operation and stopping the // stop watch, and it makes it possible for timeout to exceed // even after IO completed successfully. if (_stopwatch.ElapsedMilliseconds > _timeout) { ResetTimeout(System.Threading.Timeout.Infinite); throw new TimeoutException("Timeout in IO operation"); } }