PlatformApp.PumpEvents(timeout) blocks until the system has an event or the timeout passes. Work that arrives on another thread (a request
from a control listener, a D-Bus callback, a timer, a task continuation) calls PlatformApp.Wake() to end that wait at once, so the loop
needs no polling interval.
Wake()is safe from any thread, any number of times, at any time, including duringDispose.- It makes the current wait return; if no wait is running, the next one returns immediately. Wakes that pile up before the loop looks coalesce into one early return.
- A woken
PumpEventsqueues no event. After every return, check your own work queue. - A wake is not an event, so there is no
PlatformEventKindfor it.
| Backend | Mechanism |
|---|---|
| Wayland, X11 | A non-blocking pipe polled beside the connection descriptor. A flag keeps a burst of wakes to one byte. |
| Headless | A timed pump sleeps on a semaphore while nothing is queued; Wake releases it. |
| Win32 | An auto-reset event passed to MsgWaitForMultipleObjects beside the message queue. |
| Cocoa | An application-defined NSEvent posted with postEvent:atStart:, which may be called from any thread. |
| Android | ALooper_wake on the loop's looper. |
| Browser, iOS | No blocking wait; Wake() does nothing. |
Headless PumpEvents(timeout) used to return at once; it now waits up to timeout when no event is queued and no wake arrives.