Sleep (int milliseconds)

Windows API function; freezes the program and suspends execution for the given number of milliseconds.

wait (int n): int

Like Sleep, but does not freeze the program. The user interface remains responsive during the wait time, given by n in milliseconds. The function returns 0 when the [Stop] button was hit, otherwise nonzero. If n is negative, the function checks the [Stop] button and the user interface only every nth time, for not delaying fast loops. Use wait in a loop for avoiding unresponsiveness during long computations or external function calls. For displaying progress during very long processes, use progress instead.


Rx("TrainNeuralNet()",1); // start a long computation
while(Rrun() == 2)
  if(!wait(100)) return;  // wait until computation is finished or [Stop] was hit

See also:

timer, run, R bridge, lock, quit, version, progress

► latest version online