MainThreadDispatcher Class

Simple cross-platform dispatcher for marshaling GPU operations to the main thread. Uses only standard .NET primitives (ConcurrentQueue, Thread) for maximum compatibility.

internal sealed class MainThreadDispatcher : Brine2D.Threading.IMainThreadDispatcher

Inheritance System.Object → MainThreadDispatcher

Implements IMainThreadDispatcher

Methods
SignalShutdown() Signals that the game loop has exited. After this call, RunOnMainThreadAsync(Action, CancellationToken) and RunOnMainThread(Action, bool) execute inline on the calling thread rather than enqueuing, preventing post-shutdown deadlocks in background cleanup continuations. Should only be called by the engine's game host infrastructure.