Thread.Sleep(0) : What is the normal behavior?

It doesn’t force a context switch, only Sleep(1) does that. But if there’s any other thread from any process ready to run and has a higher priority then Sleep(0) will yield the processor and let it run. You can see this by running an endless loop that calls Sleep(0), it will burn 100% CPU cycles on one core. I don’t understand why you don’t observe this behavior.

The best way to keep the system responsive is by giving your thread a low priority.

Leave a Comment