Choosing a manual resest event here causes the loop to be busy (100% cpu) while the event is set. So there must another part in your code resetting the event or did you just forget to reset the event at the WAIT_OBJECT_0
case?
Is this good practice? Well, when the event isn't set, this code is just waiting (INFINITE
). However, when the event is set, this is just busy polling for the event to get reset.
I suspect you want to do something else in the WAIT_OBJECT_0
case and you want to have external control. You can do it that way, there is no problem using WaitForSingleObject
in a loop.