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
}