Preliminary. ThinkMeta ConcurrentTasks and this documentation are preliminary; everything is subject to change.

API reference / Schedulers

DispatcherScheduler class

Owns a dispatcher scheduler bound to the calling thread.

On this page
Use
import ThinkMeta.ConcurrentTasks.Schedulers.DispatcherScheduler;
Namespace
ThinkMeta::ConcurrentTasks::Schedulers

Syntax

Remarks

Lets event handlers on a UI thread wait without blocking it: start a handler with RunTask; when it waits, RunTask returns, and when it can go on, the scheduler hands it to the thread's event loop, which passes it to ContinueTask. Work for other threads goes to another scheduler explicitly (Tasks::Task::Schedule, Tasks::RunAndWait). Created and destroyed on the bound thread; destroyed only once no task waits or is on its way to the loop. Not copyable or movable: the scheduler keeps this object's address as the wake context. Usage rules: wait only inside the scheduler's tasks, never in other code on the bound thread; do not wait inside an activation context of your own (ActivateActCtx … wait … DeactivateActCtx).

See also

IDispatcherScheduler

Constructors

DispatcherScheduler

Creates the scheduler with a wake callback of the caller's.

Syntax

DispatcherScheduler(DispatcherWakeProc wake, void* context) noexcept;

Parameters

wakeDispatcherWakeProc
Hands tasks that can go on to the event loop; see DispatcherWakeProc.
contextvoid*
Passed to wake; must outlive the scheduler.

Creates the scheduler for a window: tasks that can go on are posted to it.

Syntax

DispatcherScheduler(HWND window, UINT message) noexcept;

Parameters

windowHWND
The window that receives the tasks; may be set later with SetWindow.
messageUINT
The message that carries a task in its lParam; the window procedure passes it to ContinueTask. Typically WM_APP + n.

Remarks

A message to a window also reaches modal loops (message boxes, moving the window, menus), so waiting handlers go on there too. A task that cannot be posted - no window set yet, the window destroyed, the thread's message queue full (10,000 posted messages by default) - would wait for ever; the process ends instead (__fastfail), also in release builds.

~DispatcherScheduler

Stops and destroys the scheduler.

Syntax

Methods

operatorbool

Returns whether the scheduler was created.

Syntax

explicit operator bool() const noexcept;

Get

Returns the core's scheduler, e.g. for ITaskScheduler::AddTask from another thread.

Syntax

IDispatcherScheduler* Get() const noexcept;

Return value

Type: IDispatcherScheduler*

operator->

Returns the core's scheduler.

Syntax

IDispatcherScheduler* operator->() const noexcept;

Return value

Type: IDispatcherScheduler*

SetWindow

Sets the window for the window constructor, if it did not exist yet then.

Syntax

void SetWindow(HWND window) noexcept;

Parameters

windowHWND
The window; set it before the first task can wait.

RunTask

Runs a task now; returns when it has ended or waits.

Syntax

void RunTask(ITask* task) noexcept;

Parameters

taskITask*
The task; must stay valid until it has exited.

Remarks

Bound thread only, typically from an event handler.

See also

IDispatcherScheduler::RunTask

ContinueTask

Continues a task the event loop got; returns when it has ended or waits again.

Syntax

void ContinueTask(SuspendedTask task) noexcept;

Parameters

taskSuspendedTask
A task handed to the event loop by this scheduler; each exactly once.

See also

IDispatcherScheduler::ContinueTask

Continues the task carried by a message of the window constructor.

Syntax

void ContinueTask(LPARAM lParam) noexcept;

Parameters

lParamLPARAM
The lParam of the message.

Generated from ThinkMeta.ConcurrentTasks.API @ e29892d (2026-10-30).