Avoid using blocking function in main thread

Here the blocking function stands for any functions that cause the current thread enter the wait state, such as Sleep(),WaitForMultipleObject() and so on.

The reason to avoid using blocking function in main thread is that if the main thread is blocked and the thread creates any windows, it can’t process any message in its message queue. Other thread in the process may become deadlocked.

In fact, it would be much better to set a timer in another working thread, so that the main thread still works.

你可能感兴趣的:(Avoid using blocking function in main thread)