addTimeout

fnvoid addTimeout(double seconds, TimeoutCallback callback)

Adds a one-shot timeout callback.

The callback will be invoked once after the specified delay. Use repeatTimeout() inside the callback to create a repeating timer.

Parameters

secondsDelay in seconds before callback is invoked
callbackFunction to call

Note

The callback is stored to prevent garbage collection.

Use removeTimeout() when the timeout is no longer needed.

Example:

addTimeout(1.0, () {
   writeln("One second passed!");
});