private bool SleepUntil(int milliseconds) { DateTime now = DateTime.UtcNow; while (this.stopCounter == 0 && (DateTime.UtcNow - now).TotalMilliseconds < milliseconds) { Thread.Sleep(100); } return this.stopCounter == 0; }