public sealed class DesktopNativeOwner : INativePickerOwner Binds native platform services to one open embedded Desktop window.
Remarks
Pass the owner to a platform provider, for example WindowsPlatformProvider.CreateFileDialogs(owner), LinuxPlatformProvider.CreateFileDialogs(owner) on Linux with GTK 3, or PortalPlatformProvider.CreateFileDialogs(Gtk4PlatformProvider.CreatePortalWindowOwner(owner)) with GTK 4 (LinuxPlatformProvider parents through GTK 3 and must not be used with a GTK 4 window). 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 INativePickerOwner.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 INativePickerOwner.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 INativePickerOwner.InvokeAsync.