Implement a Non-Blocking Delay
Version Compatibility: Visual Basic 6, Visual Basic 5
Here is the list of these functions: Sleep, SleepEx, WaitForSingleObject, WaitForSingleObjectEx, WaitForMultipleObjects, WaitForMultipleObjectsEx, MsgWaitForMultipleObjects, MsgWaitForMultipleObjectsEx, SignalObjectAndWait.
So, what problems may encounter the programmer using above API functions with?
Fortunately, there is only one problem, but it is rather serious. The thing is that the programs written on Visual Basic with a small exception are executing in one OS thread. It means that when one of wait functions starts, the "life" of the program completely stops: the visual interface freezes, the buttons became unclickable, and TaskManager reports "Not Responding". More complete discussion of this problem can be found at http://smsoft.chat.ru/en/vbwait.htm
The offered MsgWaitObj function may be used as a non-blocking equivalent of Sleep, WaitForSingleObject and WaitForMultipleObjects functions.
Instructions: Copy the declarations and code below and paste directly into your VB project.