after idle

'''after idle` schedules a script for evaluation at moment when the interpreter is idle.


after idle script ?script script ...?

See Also

Update considered harmful
Why after idle should be used instead of update or update idletasks.


Concatenates the script arguments together with space separators in the same manner as concat, arranges for the resulting script to be evaluated one time when the event loop has no active events to process, and returns an identifier that after cancel can use to cancel the evaluation. If an error occurs while executing the script the background error handler is called.

The event loop considers the system to be idle when there are no events ready to be evaluated in the normal queue. As long as any channel that is ready to be read or written and has an chan event event handler associated with it, the system is not considered idle because the event handler is continuously placed into the active queue until the channel is no longer ready.

A typical, and perhaps the most important use of after idle, is to keep a GUI alive during a long calculation. A routine can perform a little work and then reschedule itself for later:

proc dostuff {} {
    do something
    after idle [list after 0 [namespace which dostuff]]