| 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 |
# @(#) TimerHndlr.3 1.9 95/05/28 13:52:12 |
| 7 |
# |
| 8 |
|
| 9 |
=head1 NAME |
| 10 |
|
| 11 |
Tk_CreateTimerHandler, Tk_DeleteTimerHandler - call a procedure at a |
| 12 |
given time |
| 13 |
|
| 14 |
=for category C Programming |
| 15 |
|
| 16 |
=head1 SYNOPSIS |
| 17 |
|
| 18 |
B<#include E<lt>tk.hE<gt>> |
| 19 |
|
| 20 |
Tk_TimerToken |
| 21 |
B<Tk_CreateTimerHandler>(I<milliseconds, proc, clientData>) |
| 22 |
|
| 23 |
B<Tk_DeleteTimerHandler>(I<token>) |
| 24 |
|
| 25 |
=head1 ARGUMENTS |
| 26 |
|
| 27 |
=over 4 |
| 28 |
|
| 29 |
=item int milliseconds (in) |
| 30 |
|
| 31 |
How many milliseconds to wait before invoking I<proc>. |
| 32 |
|
| 33 |
=item Tk_TimerProc *proc (in) |
| 34 |
|
| 35 |
Procedure to invoke after I<milliseconds> have elapsed. |
| 36 |
|
| 37 |
=item ClientData clientData (in) |
| 38 |
|
| 39 |
Arbitrary one-word value to pass to I<proc>. |
| 40 |
|
| 41 |
=item Tk_TimerToken token (in) |
| 42 |
|
| 43 |
Token for previously-created timer handler (the return value |
| 44 |
from some previous call to B<Tk_CreateTimerHandler>). |
| 45 |
|
| 46 |
=back |
| 47 |
|
| 48 |
=head1 DESCRIPTION |
| 49 |
|
| 50 |
B<Tk_CreateTimerHandler> arranges for I<proc> to be |
| 51 |
invoked at a time I<milliseconds> milliseconds in the |
| 52 |
future. |
| 53 |
The callback to I<proc> will be made by B<Tk_DoOneEvent>, |
| 54 |
so B<Tk_CreateTimerHandler> is only useful in |
| 55 |
programs that dispatch events |
| 56 |
through B<Tk_DoOneEvent> or through other Tk procedures that |
| 57 |
call B<Tk_DoOneEvent>, such as B<Tk_MainLoop>. The call |
| 58 |
to I<proc> may not be made at the exact time given by |
| 59 |
I<milliseconds>: it will be made at the next opportunity |
| 60 |
after that time. For example, if B<Tk_DoOneEvent> isn't |
| 61 |
called until long after the time has elapsed, or if there |
| 62 |
are other pending events to process before the call to |
| 63 |
I<proc>, then the call to I<proc> will be delayed. |
| 64 |
|
| 65 |
I<Proc> should have arguments and return value that match |
| 66 |
the type B<Tk_TimerProc>: |
| 67 |
|
| 68 |
=over 4 |
| 69 |
|
| 70 |
typedef void Tk_TimerProc(ClientData I<clientData>); |
| 71 |
|
| 72 |
=back |
| 73 |
|
| 74 |
The I<clientData> parameter to I<proc> is a |
| 75 |
copy of the I<clientData> argument given to |
| 76 |
B<Tcl_CreateTimerHandler> when the callback |
| 77 |
was created. Typically, I<clientData> points to a data |
| 78 |
structure containing application-specific information about |
| 79 |
what to do in I<proc>. |
| 80 |
|
| 81 |
B<Tk_DeleteTimerHandler> may be called to delete a |
| 82 |
previously-created timer handler. It deletes the handler |
| 83 |
indicated by I<token> so that no call to I<proc> |
| 84 |
will be made; if that handler no longer exists |
| 85 |
(e.g. because the time period has already elapsed and I<proc> |
| 86 |
has been invoked) then B<Tk_DeleteTimerHandler> does nothing. |
| 87 |
|
| 88 |
=head1 KEYWORDS |
| 89 |
|
| 90 |
callback, clock, handler, timer |