after

Execute a procedure after a time delay


SYNOPSIS

(after ms)
(after ms thunk)
(after 'cancel id)
(after 'cancel thunk)
(after 'idle thunk)

DEFINITION

This procedure is used to delay execution of the program or to execute a procedure in background after a delay. It has several forms, depending on the first argument to the procedure:

(after ms)
Ms must be an integer giving a time in milliseconds. The procedure sleeps for ms milliseconds and then returns. While the procedure is sleeping the application does not respond to X events or any other events.

(after ms thunk)
In this form the procedure returns immediately, but it arranges for a STk procedure to be executed ms milliseconds later as a background event handler. The delayed procedure must be a thunk. If an error occurs while executing the delayed procedure then the tkerror mechanism is used to report the error. The after procedure returns a symbol that can be used to cancel the delayed procedure using after cancel.

(after 'cancel id)
Cancels the execution of a delayed procedure that was previously scheduled. Id indicates which procedure should be canceled; it must have been the return value from a previous after procedure. If the procedure given by id has already been executed then the after cancel procedure has no effect.

(after 'cancel thunk)
This procedure also cancels the execution of a delayed procedure. If there is a pending procedure that matches thunk, it is cancelled and will never be executed; if no such procedure is currently pending then the after cancel procedure has no effect.

(after 'idle thunk)
Arranges for the given thunk to be evaluated later as an idle handler (the thunk runs the next time the Tk event loop is entered and there are no events to process). The procedure returns an identifier that can be used to cancel the delayed procedure using after cancel. If an error occurs while executing the thunk then the tkerror mechanism is used to report the error.

SEE ALSO

tkerror
Go to top