| 1 |
# Copyright (c) 1990 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994 Sun Microsystems, Inc. |
| 3 |
# See the file "license.terms" for information on usage and redistribution |
| 4 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 5 |
# |
| 6 |
# @(#) DoWhenIdle.3 1.11 95/05/06 15:29:19 |
| 7 |
# |
| 8 |
|
| 9 |
=head1 NAME |
| 10 |
|
| 11 |
Tk_DoWhenIdle, Tk_CancelIdleCall - invoke a procedure when there are no pending events |
| 12 |
|
| 13 |
=for category C Programming |
| 14 |
|
| 15 |
=head1 SYNOPSIS |
| 16 |
|
| 17 |
B<#include E<lt>tk.hE<gt>> |
| 18 |
|
| 19 |
B<Tk_DoWhenIdle>(I<proc, clientData>) |
| 20 |
|
| 21 |
B<Tk_CancelIdleCall>(I<proc, clientData>) |
| 22 |
|
| 23 |
=head1 ARGUMENTS |
| 24 |
|
| 25 |
=over 4 |
| 26 |
|
| 27 |
=item Tk_IdleProc *proc (in) |
| 28 |
|
| 29 |
Procedure to invoke. |
| 30 |
|
| 31 |
=item ClientData clientData (in) |
| 32 |
|
| 33 |
Arbitrary one-word value to pass to I<proc>. |
| 34 |
|
| 35 |
=back |
| 36 |
|
| 37 |
=head1 DESCRIPTION |
| 38 |
|
| 39 |
B<Tk_DoWhenIdle> arranges for I<proc> to be invoked |
| 40 |
when the application becomes idle. The application is |
| 41 |
considered to be idle when B<Tk_DoOneEvent> has been |
| 42 |
called, it couldn't find any events to handle, and it is about |
| 43 |
to go to sleep waiting for an event to occur. At this |
| 44 |
point all pending B<Tk_DoWhenIdle> handlers are |
| 45 |
invoked. For each call to B<Tk_DoWhenIdle> there will |
| 46 |
be a single call to I<proc>; after I<proc> is |
| 47 |
invoked the handler is automatically removed. |
| 48 |
B<Tk_DoWhenIdle> is only useable in programs that |
| 49 |
use B<Tk_DoOneEvent> to dispatch events. |
| 50 |
|
| 51 |
I<Proc> should have arguments and result that match the |
| 52 |
type B<Tk_IdleProc>: |
| 53 |
|
| 54 |
=over 4 |
| 55 |
|
| 56 |
typedef void Tk_IdleProc(ClientData I<clientData>); |
| 57 |
|
| 58 |
=back |
| 59 |
|
| 60 |
The I<clientData> parameter to I<proc> is a copy of the I<clientData> |
| 61 |
argument given to B<Tk_DoWhenIdle>. Typically, I<clientData> |
| 62 |
points to a data structure containing application-specific information about |
| 63 |
what I<proc> should do. |
| 64 |
|
| 65 |
B<Tk_CancelIdleCall> |
| 66 |
may be used to cancel one or more previous |
| 67 |
calls to B<Tk_DoWhenIdle>: if there is a B<Tk_DoWhenIdle> |
| 68 |
handler registered for I<proc> and I<clientData>, then it |
| 69 |
is removed without invoking it. If there is more than one |
| 70 |
handler on the idle list that refers to I<proc> and I<clientData>, |
| 71 |
all of the handlers are removed. If no existing handlers match |
| 72 |
I<proc> and I<clientData> then nothing happens. |
| 73 |
|
| 74 |
B<Tk_DoWhenIdle> is most useful in situations where |
| 75 |
(a) a piece of work will have to be done but (b) it's |
| 76 |
possible that something will happen in the near future |
| 77 |
that will change what has to be done, or require something |
| 78 |
different to be done. B<Tk_DoWhenIdle> allows the |
| 79 |
actual work to be deferred until all pending events have |
| 80 |
been processed. At this point the exact work to be done |
| 81 |
will presumably be known and it can be done exactly once. |
| 82 |
|
| 83 |
For example, B<Tk_DoWhenIdle> might be used by an editor |
| 84 |
to defer display updates until all pending commands have |
| 85 |
been processed. Without this feature, redundant redisplays |
| 86 |
might occur in some situations, such as the processing of |
| 87 |
a command file. |
| 88 |
|
| 89 |
=head1 KEYWORDS |
| 90 |
|
| 91 |
callback, defer, handler, idle |