DoWhenIdle.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
- '"
- '" Copyright (c) 1990 The Regents of the University of California.
- '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: DoWhenIdle.3,v 1.2 1998/09/14 18:39:48 stanton Exp $
- '"
- .so man.macros
- .TH Tcl_DoWhenIdle 3 7.5 Tcl "Tcl Library Procedures"
- .BS
- .SH NAME
- Tcl_DoWhenIdle, Tcl_CancelIdleCall - invoke a procedure when there are no pending events
- .SH SYNOPSIS
- .nf
- fB#include <tcl.h>fR
- .sp
- fBTcl_DoWhenIdlefR(fIproc, clientDatafR)
- .sp
- fBTcl_CancelIdleCallfR(fIproc, clientDatafR)
- .SH ARGUMENTS
- .AS Tcl_IdleProc clientData
- .AP Tcl_IdleProc *proc in
- Procedure to invoke.
- .AP ClientData clientData in
- Arbitrary one-word value to pass to fIprocfR.
- .BE
- .SH DESCRIPTION
- .PP
- fBTcl_DoWhenIdlefR arranges for fIprocfR to be invoked
- when the application becomes idle. The application is
- considered to be idle when fBTcl_DoOneEventfR has been
- called, couldn't find any events to handle, and is about
- to go to sleep waiting for an event to occur. At this
- point all pending fBTcl_DoWhenIdlefR handlers are
- invoked. For each call to fBTcl_DoWhenIdlefR there will
- be a single call to fIprocfR; after fIprocfR is
- invoked the handler is automatically removed.
- fBTcl_DoWhenIdlefR is only usable in programs that
- use fBTcl_DoOneEventfR to dispatch events.
- .PP
- fIProcfR should have arguments and result that match the
- type fBTcl_IdleProcfR:
- .CS
- typedef void Tcl_IdleProc(ClientData fIclientDatafR);
- .CE
- The fIclientDatafR parameter to fIprocfR is a copy of the fIclientDatafR
- argument given to fBTcl_DoWhenIdlefR. Typically, fIclientDatafR
- points to a data structure containing application-specific information about
- what fIprocfR should do.
- .PP
- fBTcl_CancelIdleCallfR
- may be used to cancel one or more previous
- calls to fBTcl_DoWhenIdlefR: if there is a fBTcl_DoWhenIdlefR
- handler registered for fIprocfR and fIclientDatafR, then it
- is removed without invoking it. If there is more than one
- handler on the idle list that refers to fIprocfR and fIclientDatafR,
- all of the handlers are removed. If no existing handlers match
- fIprocfR and fIclientDatafR then nothing happens.
- .PP
- fBTcl_DoWhenIdlefR is most useful in situations where
- (a) a piece of work will have to be done but (b) it's
- possible that something will happen in the near future
- that will change what has to be done or require something
- different to be done. fBTcl_DoWhenIdlefR 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.
- .PP
- For example, fBTcl_DoWhenIdlefR 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 some situations, such as the processing of
- a command file.
- .SH BUGS
- .PP
- 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
- better to use a timer handler with a zero timeout period.
- .SH KEYWORDS
- callback, defer, idle callback