FindMyFiles

FindMyFiles.Engine

EngineEventMarshaler Class

The single crossing point from engine threads to the UI thread. IEngineClient events fire on engine / pipe read-loop threads; this class subscribes to all four, marshals each through TryEnqueue(Action) and re-raises it as its own event on the UI thread. Consumers (ViewModels, the orchestrator) attach plain handlers and never marshal themselves — the per-subscriber inline `dispatcher.TryEnqueue` lambdas this replaces were the audit's "scattered crossing" finding. The upstream delegates are held in fields for the subscription lifetime (the GC-rooting rule for callback delegates, satisfied structurally).

public sealed class EngineEventMarshaler : System.IDisposable

Inheritance System.Object → EngineEventMarshaler

Implements System.IDisposable

Constructors

EngineEventMarshaler(IEngineClient, IDispatcher) Constructor

Subscribes to the four events of engine, marshals each payload to the UI thread via dispatcher, and re-raises it as this class's same-named event. The upstream delegates are held in fields (subscription lifetime = GC root) and detached in Dispose().

public EngineEventMarshaler(FindMyFiles.Engine.IEngineClient engine, FindMyFiles.Services.IDispatcher dispatcher);

Parameters

engine IEngineClient

The source engine client to subscribe to.

dispatcher IDispatcher

The UI-thread marshal target.

Methods

EngineEventMarshaler.Dispose() Method

Detaches all four upstream subscriptions (after this the marshaler re-raises no further events).

public void Dispose();

Implements Dispose()

Events

EngineEventMarshaler.ConnectionChanged Event

Re-raised on the UI thread from ConnectionChanged (same payload, same order).

public event Action<EngineConnectionState>? ConnectionChanged;

Event Type

System.Action<EngineConnectionState>

EngineEventMarshaler.EngineErrorOccurred Event

Re-raised on the UI thread from EngineErrorOccurred (same severity, same order).

public event Action<int>? EngineErrorOccurred;

Event Type

System.Action<System.Int32>

EngineEventMarshaler.IndexChanged Event

Re-raised on the UI thread from IndexChanged. Payload and the engine's relative firing order are preserved (TryEnqueue is FIFO).

public event Action<string>? IndexChanged;

Event Type

System.Action<System.String>

EngineEventMarshaler.VolumeUpdated Event

Re-raised on the UI thread from VolumeUpdated (same payload, same order).

public event Action<VolumeStatus>? VolumeUpdated;

Event Type

System.Action<VolumeStatus>