Suspends program execution for a specified time.
Delay ( dTime)
The Delay procedure syntax has the following parts:
Name |
Type |
Description |
dTime |
Val Double |
Delay time in milliseconds (mSec). |
The Delay suspends program execution for the specified number of milliseconds (mSec).
The dTime parameter was changed to double in ATEasy 2023 (v12) allowing you to specify fractions of a mSec with resolution in:
● Microseconds (uSec), one millionth of a second (or one thousands of a millisecond), to use, specify multiple of 1e-3, for example, to specify 120uSec use 120e-3 as argument to lTime.
● Nanoseconds (nSec), one millionth of a millisecond, to use, specify multiple of 1e-6, for example, to specify 120nSec use 120e-6 as argument to lTime.
Accuracy of Delay in nSec, depends on the Windows operating system overhead, ATEasy run-time procedure call overhead, and the number of nSec specified. Lower nSec will results in higher inaccuracy.
When lTime is greater than 1 mSec, the thread running the Delay is not suspended completely and is polled for events and interrupts. Call the Sleep procedure suspend the thread and not use any CPU while doing that. Note that calling the sleep with long period on a thread that displays user interface will make it unresponsive. If you need to provide a long delay and you do not want to consume CPU while doing so, use the following code:
DelayEx(lmSec)
lmSec: Val Long
lStart: Long
{
lStart=Tick()
loop
lWaited=Tick()-lStart
if lmSec-lWaited<5
exitloop
endif
WaitForEvent(lmSec-lWaited)
! DoEvents() ! un-comment if you like to handle UI events while delay is called
endloop
}
You can also add calls to DoEvents at the end of the loop and to the loop to provide events pooling while delay is executed.
Delay(100) ! delay 100 milliseconds
Delay(120e-3) ! delay 120 microseconds
Delay(250e-6) ! delay 250 nanoseconds