---
name: "TimerHndlr"
section: "3tk"
platform: "linux"
package: "tk40-dev"
version: "4.0p3-5"
release: "Debian 1.3 (Bo)"
platforms: ["linux"]
url: "https://new.carta.tech/TimerHndlr/3tk"
---

# TimerHndlr(3tk)

call a procedure at a given time

```

```

## NAME

Tk\_CreateTimerHandler, Tk\_DeleteTimerHandler - call a procedure at a given time

## SYNOPSIS

```
#include <tk.h>

Tk_TimerToken
Tk_CreateTimerHandler(milliseconds, proc, clientData)

Tk_DeleteTimerHandler(token)
```

## ARGUMENTS

- int *milliseconds* (in)

  How many milliseconds to wait before invoking *proc*.

- Tk\_TimerProc *\*proc* (in)

  Procedure to invoke after *milliseconds* have elapsed.

- ClientData *clientData* (in)

  Arbitrary one-word value to pass to *proc*.

- Tk\_TimerToken *token* (in)

  Token for previously-created timer handler (the return value from some previous call to **Tk\_CreateTimerHandler**).

  ```

  ```

## DESCRIPTION

**Tk\_CreateTimerHandler** arranges for *proc* to be invoked at a time *milliseconds* milliseconds in the future. The callback to *proc* will be made by **Tk\_DoOneEvent**, so **Tk\_CreateTimerHandler** is only useful in programs that dispatch events through **Tk\_DoOneEvent** or through other Tk procedures that call **Tk\_DoOneEvent**, such as **Tk\_MainLoop**.  The call to *proc* may not be made at the exact time given by *milliseconds*:  it will be made at the next opportunity after that time.  For example, if **Tk\_DoOneEvent** isn't called until long after the time has elapsed, or if there are other pending events to process before the call to *proc*, then the call to *proc* will be delayed.

*Proc* should have arguments and return value that match the type **Tk\_TimerProc**:

```
typedef void Tk_TimerProc(ClientData clientData);
```

The *clientData* parameter to *proc* is a copy of the *clientData* argument given to **Tcl\_CreateTimerHandler** when the callback was created.  Typically, *clientData* points to a data structure containing application-specific information about what to do in *proc*.

**Tk\_DeleteTimerHandler** may be called to delete a previously-created timer handler.  It deletes the handler indicated by *token* so that no call to *proc* will be made;  if that handler no longer exists (e.g. because the time period has already elapsed and *proc* has been invoked) then **Tk\_DeleteTimerHandler** does nothing.

## KEYWORDS

callback, clock, handler, timer
