FindMyFiles

FindMyFiles.Services

ServiceProvisioner Class

The shared "make file search usable" steps, behind both the setup screen's one-click button and the management dialog's register action: register the fmf-engine service elevated, then wait for its pipe to start serving and relaunch so this (unelevated, empty-fake) instance comes back connected. The engine transport is chosen once at startup, so a relaunch is how a freshly registered service takes effect.

Instance-based so the elevated setup, the pipe probe, the relaunch and the inter-probe delay are injectable boundaries (ADR-0022) — production code uses Real, which wires the real statics; tests drive fakes.

public sealed class ServiceProvisioner

Inheritance System.Object → ServiceProvisioner

Properties

ServiceProvisioner.Real Property

The production provisioner: the real elevated setup, the real pipe probe, Relaunch(), and System.Threading.Tasks.Task.Delay(System.TimeSpan). Callers default to this.

public static FindMyFiles.Services.ServiceProvisioner Real { get; }

Property Value

ServiceProvisioner

Methods

ServiceProvisioner.RegisterAsync() Method

install (idempotent) + restart in one elevated step (the fmf-service `setup` verb), forwarding the daily user's SID so OTS elevation doesn't lock them out (docs/SECURITY.md threat 1). Blocking work runs off the UI thread.

public System.Threading.Tasks.Task<FindMyFiles.Services.ServiceActionOutcome> RegisterAsync();

Returns

System.Threading.Tasks.Task<ServiceActionOutcome>
The outcome of the elevated setup step (success, declined, or failed).

ServiceProvisioner.WaitForServiceThenRelaunchAsync() Method

After register/start the service's pipe needs a moment to start serving — poll until it answers (≈8s budget), then relaunch this app so the fresh instance connects. Returns false if the pipe never came up in time (the caller then offers a manual retry). On success this process exits and never returns.

public System.Threading.Tasks.Task<bool> WaitForServiceThenRelaunchAsync();

Returns

System.Threading.Tasks.Task<System.Boolean>
True once the pipe answered and a relaunch was triggered; false if it never came up in time.