Returns when any user action or event is signaled or time-out occurs. The waiting for an event is very efficient as no CPU resources are consumed.
WaitForEvent ( [lTimeout] )
The WaitForEvent property syntax has the following part:
Name |
Type |
Description |
lTimeout |
[Val] Long |
The time-out interval in milliseconds. This is optional. The default is infinite (-1); that is, the function's time-out interval never elapses. |
The WaitForEvent function has no return value. It waits until any user action or event triggers a return or until the set time-out interval elapses. Examples of user action or event are any mouse movement or keyboard action or timer set. During the wait, no CPU resources are consumed.
You can find the following example from ATEasy's TestExec project, in a TestExec driver procedure called Wait. The example shows the wait for a return until the user takes an action on the Main form:
m_frmMain.Update(enCause)
!wait until the user does something
while m_bWait
DoEvents()
WaitForEvent(100) !don't consume 100% cpu
endwhile
AEvent, AMutex, ASemaphore, CreateThread, Delay, DoEvents, Sleep, Tick, WaitForMultipleObjects, WaitForSingleObject, Load