after

Execute a command after a time delay

SYNOPSIS

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

DESCRIPTION

The after 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 procedure will be executed exactly once, at the given time. 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 script will be run exactly once, 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 script then the tkerror mechanism is used to report the error.

(after 'info id)
(after 'info)
This procedure returns information about existing event handlers. If no id argument is supplied, then the procedure returns a list of the identifiers for all existing event handlers created by the after procedure for this interpreter. If id is supplied, it specifies an existing handler; id must have been the return value from some previous call to after and it must not have triggered yet or been cancelled. In this case the procedure returns a list with two elements. The first element of the list is the script associated with id, and the second element is either idle or timer to indicate what kind of event handler it is.

SEE ALSO

tkerror

Back to the STk main page