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
contextSynchronizationContextThe context to post to, or
nullto 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
Post(Action)
Queues action for asynchronous execution on the UI thread.
public void Post(Action action)
Parameters
actionActionThe work to execute on the UI thread.