I need to wait some time in one of my threads, I started to think about WaitForSingleObject but it needs handles to wait on, although it can take a timeout input;
Another resolution may use SetTimer but it seems that it will create WM_TIMER message but I don’t have change to catch that message since I am in a thread, so is there something I can use here ? can I use Sleep?
The proper method strongly depends on what you mean with
to wait some time. The Sleep function and the WaitForSingleObject function are basically of the same accuracy.Depending on the underlaying hardware and the version of the OS minimum delays achievable are in the range of 0 .. 1 .. 20ms. If you desire to just wait for seconds or 10th of seconds these two functions are the right choice.
Waiting for shorter periods in time i.e. in the millisecond range needs more detailed investigation. See this or this answer for more details.