On Fri, 13 Feb 2004 22:30:33 +1300, "Stephen Williams"
<st*****@hotmail.com> wrote:
I want to add a 2 secondish pause to a program, i can't find any nice and
easy commands that will do it. I looked at the timer control but i can't
seem to see how it will help.
Timer1.Interval = 0.1
Timer1.Enabled = True
FinishedTime = DateAdd( "s", 2, Now )
While Now < FinishedTime
WaitMessage ' an API
DoEvents
Wend
Timer1.Enabled = False
The Timer pulses a Windows message to your App
WaitMessage 'idles' your App and does not return until there is a
Windows message to process
DoEvents keeps your App responding
The problem with omitting the WaitMessage is that your App is
hammering away inside the loop - wasting CPU time
The problem with Sleep( N ) is that for N seconds your App is simply
'dead' to the world
WaitMessage without the Timer pulse would only check for the elapsed
period /after/ a Windows message - and if you leave the mouse and
keyboard alone, this could be a very long time.