What is the impact of Thread.Sleep(1) in C#?

As stated, your loop will not hog the CPU.

But beware: Windows is not a real-time OS, so you will not get 1000 wakes per second from Thread.Sleep(1). If you haven’t used timeBeginPeriod to set your minimum resolution you’ll wake about every 15 ms. Even after you’ve set the minimum resolution to 1 ms, you’ll still only wake up every 3-4 ms.

In order to get millisecond level timer granularity you have to use the Win32 multimedia timer (C# wrapper).

Leave a Comment