FindMyFiles

FindMyFiles.Services

DispatcherQueueDispatcher Class

Production IDispatcher: a thin wrapper over the UI thread's cached Microsoft.UI.Dispatching.DispatcherQueue (CLAUDE.md UI rules — cache on the UI thread, TryEnqueue from background threads).

public sealed class DispatcherQueueDispatcher : FindMyFiles.Services.IDispatcher

Inheritance System.Object → DispatcherQueueDispatcher

Implements IDispatcher

Constructors

DispatcherQueueDispatcher(DispatcherQueue) Constructor

Production IDispatcher: a thin wrapper over the UI thread's cached Microsoft.UI.Dispatching.DispatcherQueue (CLAUDE.md UI rules — cache on the UI thread, TryEnqueue from background threads).

public DispatcherQueueDispatcher(Microsoft.UI.Dispatching.DispatcherQueue queue);

Parameters

queue Microsoft.UI.Dispatching.DispatcherQueue

The UI thread's Microsoft.UI.Dispatching.DispatcherQueue, captured once on that thread at construction.

Properties

DispatcherQueueDispatcher.HasThreadAccess Property

True when the caller is already on the UI thread.

public bool HasThreadAccess { get; }

Implements HasThreadAccess

Property Value

System.Boolean

Methods

DispatcherQueueDispatcher.CreateOneShotTimer(TimeSpan, Action) Method

One-shot timer: fires tick once per Start(). Start() while pending restarts the interval (debounce semantics).

public FindMyFiles.Services.IDispatcherTimer CreateOneShotTimer(System.TimeSpan interval, System.Action tick);

Parameters

interval System.TimeSpan

Delay between Start() and the tick.

tick System.Action

Callback fired on the UI thread when the interval elapses.

Implements CreateOneShotTimer(TimeSpan, Action)

Returns

IDispatcherTimer
A restartable timer handle bound to this dispatcher.

DispatcherQueueDispatcher.TryEnqueue(Action) Method

Queue action to run on the UI thread. Returns false if the queue is shutting down and the work was not accepted.

public bool TryEnqueue(System.Action action);

Parameters

action System.Action

Work to marshal onto the UI thread.

Implements TryEnqueue(Action)

Returns

System.Boolean
True if enqueued; false if the dispatcher is no longer accepting work.