Table of Contents

Class SynchronizationContextUiDispatcher

Namespace
DotNetQuery.Mvvm
Assembly
DotNetQuery.Mvvm.dll

An IUiDispatcher backed by a SynchronizationContext. When the context is null, actions are invoked inline on the calling thread — useful in unit tests and console applications that have no UI thread.

public sealed class SynchronizationContextUiDispatcher : IUiDispatcher
Inheritance
SynchronizationContextUiDispatcher
Implements
Inherited Members

Constructors

SynchronizationContextUiDispatcher(SynchronizationContext?)

An IUiDispatcher backed by a SynchronizationContext. When the context is null, actions are invoked inline on the calling thread — useful in unit tests and console applications that have no UI thread.

public SynchronizationContextUiDispatcher(SynchronizationContext? context)

Parameters

context SynchronizationContext

The context to post to, or null to invoke actions inline.

Methods

CaptureCurrent()

Creates a dispatcher targeting Current. Call this on the UI thread; when called where no context is installed (unit tests, console apps), the resulting dispatcher invokes actions inline.

public static SynchronizationContextUiDispatcher CaptureCurrent()

Returns

SynchronizationContextUiDispatcher

Post(Action)

Queues action for asynchronous execution on the UI thread.

public void Post(Action action)

Parameters

action Action

The work to execute on the UI thread.