| 1 |
'\" |
| 2 |
'\" Copyright (c) 1990 The Regents of the University of California. |
| 3 |
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 4 |
'\" |
| 5 |
'\" See the file "license.terms" for information on usage and redistribution |
| 6 |
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 7 |
'\" |
| 8 |
.TH Tcl_CreateTimerHandler 3 7.5 Tcl "Tcl Library Procedures" |
| 9 |
.so man.macros |
| 10 |
.BS |
| 11 |
.SH NAME |
| 12 |
Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler \- call a procedure at a given time |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
\fB#include <tcl.h>\fR |
| 16 |
.sp |
| 17 |
Tcl_TimerToken |
| 18 |
\fBTcl_CreateTimerHandler\fR(\fImilliseconds, proc, clientData\fR) |
| 19 |
.sp |
| 20 |
\fBTcl_DeleteTimerHandler\fR(\fItoken\fR) |
| 21 |
.SH ARGUMENTS |
| 22 |
.AS Tcl_TimerToken milliseconds |
| 23 |
.AP int milliseconds in |
| 24 |
How many milliseconds to wait before invoking \fIproc\fR. |
| 25 |
.AP Tcl_TimerProc *proc in |
| 26 |
Procedure to invoke after \fImilliseconds\fR have elapsed. |
| 27 |
.AP ClientData clientData in |
| 28 |
Arbitrary one-word value to pass to \fIproc\fR. |
| 29 |
.AP Tcl_TimerToken token in |
| 30 |
Token for previously created timer handler (the return value |
| 31 |
from some previous call to \fBTcl_CreateTimerHandler\fR). |
| 32 |
.BE |
| 33 |
.SH DESCRIPTION |
| 34 |
.PP |
| 35 |
\fBTcl_CreateTimerHandler\fR arranges for \fIproc\fR to be |
| 36 |
invoked at a time \fImilliseconds\fR milliseconds in the |
| 37 |
future. |
| 38 |
The callback to \fIproc\fR will be made by \fBTcl_DoOneEvent\fR, |
| 39 |
so \fBTcl_CreateTimerHandler\fR is only useful in programs that |
| 40 |
dispatch events through \fBTcl_DoOneEvent\fR or through Tcl commands |
| 41 |
such as \fBvwait\fR. |
| 42 |
The call to \fIproc\fR may not be made at the exact time given by |
| 43 |
\fImilliseconds\fR: it will be made at the next opportunity |
| 44 |
after that time. For example, if \fBTcl_DoOneEvent\fR is not |
| 45 |
called until long after the time has elapsed, or if there |
| 46 |
are other pending events to process before the call to |
| 47 |
\fIproc\fR, then the call to \fIproc\fR will be delayed. |
| 48 |
.PP |
| 49 |
\fIProc\fR should have arguments and return value that match |
| 50 |
the type \fBTcl_TimerProc\fR: |
| 51 |
.PP |
| 52 |
.CS |
| 53 |
typedef void \fBTcl_TimerProc\fR( |
| 54 |
ClientData \fIclientData\fR); |
| 55 |
.CE |
| 56 |
.PP |
| 57 |
The \fIclientData\fR parameter to \fIproc\fR is a |
| 58 |
copy of the \fIclientData\fR argument given to |
| 59 |
\fBTcl_CreateTimerHandler\fR when the callback |
| 60 |
was created. Typically, \fIclientData\fR points to a data |
| 61 |
structure containing application-specific information about |
| 62 |
what to do in \fIproc\fR. |
| 63 |
.PP |
| 64 |
\fBTcl_DeleteTimerHandler\fR may be called to delete a |
| 65 |
previously created timer handler. It deletes the handler |
| 66 |
indicated by \fItoken\fR so that no call to \fIproc\fR |
| 67 |
will be made; if that handler no longer exists |
| 68 |
(e.g. because the time period has already elapsed and \fIproc\fR |
| 69 |
has been invoked then \fBTcl_DeleteTimerHandler\fR does nothing. |
| 70 |
The tokens returned by \fBTcl_CreateTimerHandler\fR never have |
| 71 |
a value of NULL, so if NULL is passed to \fBTcl_DeleteTimerHandler\fR |
| 72 |
then the procedure does nothing. |
| 73 |
.SH "SEE ALSO" |
| 74 |
after(n), Tcl_CreateFileHandler(3), Tcl_DoWhenIdle(3) |
| 75 |
.SH KEYWORDS |
| 76 |
callback, clock, handler, timer |