Пример #1
0
        public void Sleep_Waits()
        {
            // Arrange
            var       start = DateTime.UtcNow;
            const int millisecondsToSleep = 30;

            // Act
            _target.Sleep(millisecondsToSleep);
            var end = DateTime.UtcNow;

            // Assert
            double timeToComplete = (end - start).TotalMilliseconds;

            timeToComplete.Should().BeGreaterOrEqualTo(millisecondsToSleep);
        }
Пример #2
0
        public virtual void Dispose()
        {
            try
            {
                SendRemainingCommands();

                if (MillisecondsSinceLastTransmition() < MinMillisecondsSinceLastTransmission)
                {
                    ThreadSleeper.Sleep(MinMillisecondsSinceLastTransmission);
                }
            }
            catch
            {
                // ignore
            }

            Socket.Dispose();
        }