FindMyFiles
FindMyFiles.Engine
PipeEngineClient Class
Engine client over the fmf-service named pipe (docs/ARCHITECTURE.md "Pipe protocol"). This class is the connection *supervisor* plus the request multiplexing table; the established connection itself (stream, read loop, serialized writer, epoch) is one FindMyFiles.Engine.PipeConnection object, replaced wholesale on every (re)connect. The supervisor loop: connect → server-is-SYSTEM check (default pipe name only; SECURITY.md Threat 4) → Hello (version check; a mismatch is fatal) → Subscribe → IndexStatus (synthesized VolumeUpdated + IndexChanged) → Connected. On disconnect every pending request fails fast with EngineUnavailableException, live results turn stale because their connection's epoch can never be current again, and reconnection retries forever with 250ms→5s backoff. Events fire on the read-loop thread — consumers marshal (see EngineEventMarshaler), same contract as the FFI client. No DispatcherQueue dependency.
public sealed class PipeEngineClient : FindMyFiles.Engine.IEngineClient, System.IDisposable
Inheritance System.Object → PipeEngineClient
Implements IEngineClient, System.IDisposable
Constructors
PipeEngineClient(string) Constructor
Connects to the fmf-service named pipe and starts the supervisor loop immediately. pipeName defaults to FindMyFiles.Engine.PipeProtocol.DefaultPipeName; only that default name has its server identity verified (SECURITY.md Threat 4) — a custom name (tests) skips the SYSTEM check.
public PipeEngineClient(string pipeName="fmf-engine-v2");
Parameters
pipeName System.String
Pipe to connect to, as either the short name or
the full \\.\pipe\… path.
Properties
PipeEngineClient.Connection Property
InProc for Ffi/Fake (fixed, never raises ConnectionChanged); the pipe client moves through Connecting/Connected/Reconnecting.
public FindMyFiles.Engine.EngineConnectionState Connection { get; }
Implements Connection
Property Value
Methods
PipeEngineClient.Dispose() Method
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose();
Implements Dispose()
PipeEngineClient.GetStatsAsync(CancellationToken) Method
Observability snapshot for the performance panel.
public System.Threading.Tasks.Task<FindMyFiles.Engine.EngineStatsData?> GetStatsAsync(System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters
ct System.Threading.CancellationToken
Cooperative cancellation token.
Implements GetStatsAsync(CancellationToken)
Returns
System.Threading.Tasks.Task<EngineStatsData>
The current engine stats, or null if unavailable.
PipeEngineClient.GetStatusAsync(CancellationToken) Method
Returns a snapshot of the current state (VolumeStatus) of every volume. Used for the initial display at startup and for the setup screen's decisions.
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<FindMyFiles.Engine.VolumeStatus>> GetStatusAsync(System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters
ct System.Threading.CancellationToken
Cooperative cancellation token.
Implements GetStatusAsync(CancellationToken)
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<VolumeStatus>>
A snapshot of the current status of every known volume.
Exceptions
EngineUnavailableException
service unreachable
PipeEngineClient.ListVolumesAsync(CancellationToken) Method
Returns the labels of the indexed volumes (those the engine currently recognizes).
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>> ListVolumesAsync(System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters
ct System.Threading.CancellationToken
Cooperative cancellation token.
Implements ListVolumesAsync(CancellationToken)
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<System.String>>
The labels of the volumes the engine currently knows about.
Exceptions
EngineUnavailableException
service unreachable
PipeEngineClient.Probe(string, TimeSpan) Method
Can a server be reached and Hello'd on this pipe within the timeout? Used by the factory's `auto` mode (250ms budget).
public static bool Probe(string pipeName, System.TimeSpan timeout);
Parameters
pipeName System.String
Pipe to probe, short name or full path.
timeout System.TimeSpan
Budget for connect plus the Hello round-trip.
Returns
System.Boolean
True if a protocol-compatible server answered within the timeout.
PipeEngineClient.SearchAsync(string, SearchOptions, CancellationToken) Method
Executes the query and returns a sort-settled result handle (Result) plus an optional timing trace. Pages are read lazily through the returned ISearchResult.
public System.Threading.Tasks.Task<FindMyFiles.Engine.SearchOutcome> SearchAsync(string query, FindMyFiles.Engine.SearchOptions options, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters
query System.String
The query text to execute.
options SearchOptions
Search options (sort order, flags).
ct System.Threading.CancellationToken
Cooperative cancellation token.
Implements SearchAsync(string, SearchOptions, CancellationToken)
Returns
System.Threading.Tasks.Task<SearchOutcome>
The sort-ordered result handle plus an optional timing trace.
Exceptions
QuerySyntaxException
malformed query text
EngineUnavailableException
service unreachable
PipeEngineClient.StartIndexingAsync(IReadOnlyList<string>, CancellationToken) Method
Requests that indexing/re-indexing start for the given volumes (fire-and-trigger: progress arrives via VolumeUpdated / IndexChanged). MFT reads require elevation, so the work runs on the service side.
public System.Threading.Tasks.Task StartIndexingAsync(System.Collections.Generic.IReadOnlyList<string> volumes, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters
volumes System.Collections.Generic.IReadOnlyList<System.String>
Labels of the volumes to (re)index.
ct System.Threading.CancellationToken
Cooperative cancellation token.
Implements StartIndexingAsync(IReadOnlyList<string>, CancellationToken)
Returns
System.Threading.Tasks.Task
A task that completes once the indexing request is accepted.
Exceptions
EngineUnavailableException
service unreachable
Events
PipeEngineClient.ConnectionChanged Event
Fires when the current Connection transitions. In-proc implementations never fire (always InProc). Fires from the pipe client's supervisor thread → marshal.
public event Action<EngineConnectionState>? ConnectionChanged;
Implements ConnectionChanged
Event Type
System.Action<EngineConnectionState>
PipeEngineClient.EngineErrorOccurred Event
The engine recorded a diagnostic (1=warn 2=error 3=panic). Details live in RecentErrors — pull on demand.
public event Action<int>? EngineErrorOccurred;
Implements EngineErrorOccurred
Event Type
PipeEngineClient.IndexChanged Event
New index content was published (USN apply or scan progress). The payload is the triggering volume label. The signal to re-evaluate the displayed query. Fires from an engine thread, so marshal to the UI thread (EngineEventMarshaler is the only crossing point).
public event Action<string>? IndexChanged;
Implements IndexChanged
Event Type
PipeEngineClient.VolumeUpdated Event
One volume's state transitioned (`Scanning`→`Ready` etc.). Emits the latest VolumeStatus. Fires from an engine thread → marshal.
public event Action<VolumeStatus>? VolumeUpdated;
Implements VolumeUpdated