New to Analytica 5.0

Sleep( seconds, untilTime )

Process any pending windows redraw events, and pause the computation for a specified number of seconds, or until a specified time. While paused, CPU resources are not used except when Windows events are processed.


  • «seconds»: (Optional) Number of seconds to pause for. This can be a fraction, for example, Sleep(50m) pauses for 50 milliseconds:
  • «untilTime»: (Optional) A date-time value that it should wait until. When this is a time without a date part, it sleeps until the next occurrence of that time (i.e., between 1ms and 24 hours). If there is a date part, then it returns immediately if the current local time is after the specified time.

In the most common usage, only one parameter is specified, either «seconds» or «untilTime».

When called with no parameters, it processes any pending Windows redraw events. In general, when Analytica is computing and parts of windows need to be redrawn, or other user-interactions need to be processed, these are handled while the computation is in progress, but not always immediately, since the handling of these events is interspersed with the computation. Sleep() or equivalently Sleep(0) can be used to force these events to be flushed immediately.

When both parameters are specified, it sleeps until both criteria are satisfied.


Sleep() → Process any pending Windows events (usually redraw events) and return immediately. Same as Sleep(0).
Sleep(60) → Pause computation for one minute
Sleep(50m) → Sleep for 50 milliseconds
Sleep(untilTime:9:45:00) → Sleep until 9:45am local time. If the current time is 10am, this would sleep for 23 hours and 45 minutes. If the current time is 9:40am, this would sleep for 5 minutes.
Sleep(untilTime:Today() + MakeTime(9,45,0)) → Sleep until 9:45am today. It the current time is 10am, this returns immediately (after handling any pending redraw events).
Sleep(seconds:30, untilTime:Ceil(Today(true), dateUnit:'m') ) → Sleeps for a minimum of 30 seconds, or until the next even minute boundary if that is more than 30 seconds from now.

Array parameters

It doesn't usually make much sense to use Sleep with array parameters.

See Also


You are not allowed to post comments.