Seth Woolley's Man Viewer

Tcl_DoWhenIdle(3) - Tcl_CancelIdleCall, Tcl_DoWhenIdle - invoke a procedure when there are no pending events - man 3 Tcl_DoWhenIdle

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

Tcl_DoWhenIdle(3)           Tcl Library Procedures           Tcl_DoWhenIdle(3)



______________________________________________________________________________

NAME
       Tcl_DoWhenIdle,  Tcl_CancelIdleCall - invoke a procedure when there are
       no pending events

SYNOPSIS
       #include <tcl.h>

       Tcl_DoWhenIdle(proc(5,n), clientData)

       Tcl_CancelIdleCall(proc(5,n), clientData)

ARGUMENTS
       Tcl_IdleProc   *proc(5,n)        (in(1,8))      Procedure to invoke.

       ClientData     clientData   (in(1,8))      Arbitrary one-word value to  pass
                                             to proc(5,n).
_________________________________________________________________


DESCRIPTION
       Tcl_DoWhenIdle  arranges  for  proc(5,n)  to be invoked when the application
       becomes  idle.   The  application  is  considered  to  be   idle   when
       Tcl_DoOneEvent has been called, couldn't find any events to handle, and
       is about to go to sleep(1,3) waiting for an event to occur.  At  this  point
       all  pending  Tcl_DoWhenIdle  handlers  are  invoked.  For each call to
       Tcl_DoWhenIdle there will be a single call  to  proc(5,n);   after  proc(5,n)  is
       invoked  the  handler is automatically removed.  Tcl_DoWhenIdle is only
       usable in(1,8) programs that use Tcl_DoOneEvent to dispatch events.

       Proc should have arguments and result that match the type Tcl_IdleProc:
              typedef void Tcl_IdleProc(ClientData clientData);
       The  clientData  parameter to proc(5,n) is a copy of the clientData argument
       given to Tcl_DoWhenIdle.  Typically, clientData points to a data struc-
       ture containing application-specific information about what proc(5,n) should
       do.

       Tcl_CancelIdleCall may be used to cancel one or more previous calls  to
       Tcl_DoWhenIdle:   if(3,n)  there  is a Tcl_DoWhenIdle handler registered for
       proc(5,n) and clientData, then it is removed without invoking it.  If  there
       is  more  than  one  handler  on  the idle list that refers to proc(5,n) and
       clientData, all of the handlers are removed.  If no  existing  handlers
       match proc(5,n) and clientData then nothing happens.

       Tcl_DoWhenIdle  is  most useful in(1,8) situations where (a) a piece of work
       will have to be done but (b) it's possible that something  will  happen
       in(1,8)  the  near  future  that  will change what has to be done or require
       something different to be done.  Tcl_DoWhenIdle allows the actual  work
       to  be  deferred until all pending events have been processed.  At this
       point the exact work to be done will presumably be known and it can  be
       done exactly once.

       For example, Tcl_DoWhenIdle might be used by an editor to defer display
       updates until all pending commands have been processed.   Without  this
       feature,  redundant  redisplays might occur in(1,8) some situations, such as
       the processing of a command file.

BUGS
       At present it is not safe for an idle  callback  to  reschedule  itself
       continuously.   This  will  interact  badly with certain features of Tk
       that attempt to wait for all idle callbacks to complete.  If you  would
       like for an idle callback to reschedule itself continuously, it is bet-
       ter to use a timer handler with a zero timeout(1,3x,3x cbreak) period.


KEYWORDS
       callback, defer, idle callback



Tcl                                   7.5                    Tcl_DoWhenIdle(3)

References for this manual (incoming links)