Version 4 of every

Updated 2004-07-26 16:09:23 by lwv

Credit RS with canonicalization of

    proc every {ms body} {eval $body; after $ms [info level 0]}

In the case of a body/script that takes a considerable time fraction of the interval time, the following every is more precise, provided the script under repetitive execution will normally not execute longer than the interval duration:

    proc every {ms body} {after $ms [info level 0]; eval $body}

The after command is set up prior to the script call (RJM).

FPX: Note that the latter may not be a good idea if the body (a) may in fact take longer to execute than the interval, and (b) invokes, at some point, the event loop. In that case, you might want to guard against reentrancy.


Category Command