Board index » delphi » wait/pause

wait/pause


2004-07-09 01:10:14 AM
delphi118
How do you do a pause in Delphi? I want my application to pause for 2 seconds while a DOS command I execute finishes. WaitFor doesn't seem to be what I want.
TIA
 
 

Re:wait/pause

Quote
How do you do a pause in Delphi?
SysUtils.Sleep(2000) will do the job. It takes the time to be paused
in milliseconds.
Steve
 

Re:wait/pause

Quote
How do you do a pause in Delphi? I want my application to pause for
2 seconds while a DOS command I execute finishes. WaitFor doesn't
seem to be what I want. TIA
For waiting a specific time Sleep is the way to go, like Steve says
(Sleep is not very accurate, but that doesn't seem to be a problem
here).
For waiting for a program to finish, however, WaitForSingleObject is
more appropriate. If you pass the process handle to this API function
it will wait until the application has terminated in the most efficient
possible way (no CPU load). This process handle is returned by
CreateProcess or ShellExecute.
 

Re:wait/pause

Thanks so much for this. it is been driving me nuts. For future reference, how could I have found this Sleep function in Delphi Help. I still can not find it.
"Steve Heights" <anaconda51(AT)gmx.net>writes:
Quote
>How do you do a pause in Delphi?

SysUtils.Sleep(2000) will do the job. It takes the time to be paused
in milliseconds.


Steve


 

Re:wait/pause

Quote
Thanks so much for this. it is been driving me nuts. For future
reference, how could I have found this Sleep function in Delphi Help.
I still can not find it.
Enter Sleep in the unit editor and press F1 whe your cursor is on this
word. For me (Delphi 7) this will result in a list with three possible
help topics, including "Sleep Procedure (Object and Component reference
(Common))", which is the correct one.
If you don't know the function name it is harder of course. One way
would be to use Google - if you choose your search query correctly
you're very likely to find it.
Another approach is using the categories in the Delphi help. You would
then look up a related function and click the name of it is category.
You will the get a list of related functions, perhaps including the one
you were searching for. In the case of Sleep this category is called
"Flow control routines" and also includes functions like Abort, Break,
Continue, Exit and Halt.