When implementing a spin on a certain condition I use Sleep(0) inside the while loop to yield the processor in case the condition is not satisfied. The problem with this is that I have no idea to which thread I'm giving control and also when my thread will be rescheduled. I've found SwitchToThread() to be an alternative and from what I understand, the calling thread will only yield to same or higher priority threads and it will also be immediately rescheduled.
Unfortunately, documentation on this function seems to be very scarce on the internet. Does anyone have more information about it?