-
1
- #1
In the past I would use this function to have the program 'wait' for another call to finish.
However, doing that could delay the response when starting or using other Windows apps. However, MsgWaitForMultipleObjectsEx function is preferred for desktop apps because it can co-exist better with other Windows apps. Here is a sample usage:
Source link:
MSDN: You have to be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you have a thread that uses Sleep with infinite delay, the system will deadlock. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use ... MsgWaitForMultipleObjectsEx, rather than Sleep.
Code:
DECLARE Sleep IN kernel32 INTEGER dwMilliseconds
Sleep(1000) && 1 second
However, doing that could delay the response when starting or using other Windows apps. However, MsgWaitForMultipleObjectsEx function is preferred for desktop apps because it can co-exist better with other Windows apps. Here is a sample usage:
Code:
DECLARE MsgWaitForMultipleObjectsEx IN WIN32API INTEGER nCount, INTEGER @pHandles, INTEGER dwMilliseconds, INTEGER dwWakeMask, INTEGER dwFlags
MsgWaitForMultipleObjectsEx( 0, 0, 1000, 0x40, 0 ) && 1000 = 1 second
MSDN: You have to be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you have a thread that uses Sleep with infinite delay, the system will deadlock. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use ... MsgWaitForMultipleObjectsEx, rather than Sleep.