---
name: "MainLoop"
section: "3"
platform: "macos"
package: "tcl"
version: "152"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/MainLoop"
---

# MainLoop(3)

loop for events until all windows are deleted

## NAME

Tk\_MainLoop - loop for events until all windows are deleted

## SYNOPSIS

```
#include <tk.h>

Tk_MainLoop()
```

## DESCRIPTION

**Tk\_MainLoop** is a procedure that loops repeatedly calling **Tcl\_DoOneEvent**.  It returns only when there are no applications left in this process (i.e. no main windows exist anymore).  Most windowing applications will call **Tk\_MainLoop** after initialization; the main execution of the application will consist entirely of callbacks invoked via **Tcl\_DoOneEvent**.

## KEYWORDS

application, event, main loop
