ATEasy's Sleep(), Delay() and WaitForEvent() Functions Usage

Knowledge Base Article # Q200041

Read Prior Article Read Next Article
Summary Sleep() suspends the thread from which it was called (meaning it will also suspend UI such as form events, painting, etc.). Article discuss a workaround for the Sleep().
Solution:

Sleep suspends the thread from which it was called (meaning it will also suspend UI such as form events, painting, etc.). If you wish to create an interval of time, you may call Delay() instead. However, Delay() consumes CPU time (see knowledge base article Q200030).

If that is a problem, you can use the following code:

Procedure DelayEx(lDelay)
{
lStart=Tick()

loop
   lTime=Tick()
   if lTime-lStart>lDelay than exitloop
   WaitForEvent(lStart+lDelay-Time)
   ! optional - call DoEvent() if you are calling this from a form event
endloop
}
Article Date 12/6/2002 9:56:06 AM
Keywords ATEasy, Sleep(), Delay(), WaitForEvent()

0 ratings | 0 out of 5
Read Prior Article Read Next Article