Thread.Sleep for less than 1 millisecond

You can’t do this. A single sleep call will typically block for far longer than a millisecond (it’s OS and system dependent, but in my experience, Thread.Sleep(1) tends to block for somewhere between 12-15ms).

Windows, in general, is not designed as a real-time operating system. This type of control is typically impossible to achieve on normal (desktop/server) versions of Windows.

The closest you can get is typically to spin and eat CPU cycles until you’ve achieved the wait time you want (measured with a high performance counter). This, however, is pretty awful – you’ll eat up an entire CPU, and even then, you’ll likely get preempted by the OS at times and effectively “sleep” for longer than 1ms…

Leave a Comment