public sealed class DesktopNativeOwner : INativeWindowOwner Binds native platform services to one open embedded Desktop window.
Remarks
DesktopPlatformServices.ForWindow and services.AddRunicPlatformServices() select the provider for the running backend and create the window services with this owner. Pass it where an API asks for a window, such as WindowsElevationOptions.Owner for the UAC prompt. The owner belongs to the DesktopWindow it was created for: it becomes unavailable when that window closes or the surface opens a replacement, and a replacement window needs a new owner. The native handle is passed only to callbacks running on the window's native thread and must not outlive them. DesktopNativeOwner.IsAvailable is false for any window without native dispatch, for example an installed-browser presentation or a custom window host without a native handle. Create and dispose owner-bound services while the window is open.
Constructors
DesktopNativeOwner
public DesktopNativeOwner(DesktopWindow window) Creates an owner for window.
Parameters
windowThe Desktop window whose native thread runs provider callbacks.
Properties
Generation
public Guid Generation { get; } The verified presentation generation, shared with its lifetime.
Remarks
Each owner has its own generation; an owner never follows a replacement window.
Documentation from INativeWindowOwner.Generation.
IsAvailable
public bool IsAvailable { get; } Whether the provider can currently show dialogs.
Remarks
true while the window is the surface's current embedded window, is open, and supports native dispatch.
Documentation from INativeWindowOwner.IsAvailable.
Methods
CheckAccess
public bool CheckAccess() Gets whether the caller is running on the window's native thread.
InvokeAsync
public ValueTask InvokeAsync(Action<nint> action, CancellationToken cancellationToken = default) Revalidates owner identity and dispatches on its native thread. The handle cannot escape the callback.
Exceptions
OwnerClosedExceptionThe window closed or was replaced before the callback started.
Documentation from INativeWindowOwner.InvokeAsync.