public sealed class DesktopBridgeWindow<TViewModel> : IBridgeWindow, IAsyncDisposable where TViewModel : class Owns one Desktop surface, presentation, ViewModel scope, and Views session.
Properties
NativeOwner
public DesktopNativeOwner NativeOwner { get; } The native platform-service owner of the opened presentation.
Exceptions
InvalidOperationExceptionThe presentation has not opened, or the window serves without one.
Remarks
Pass it to the platform provider for the window's backend for file dialogs, file launchers and clipboard access, or let services.AddRunicPlatformServices() bind IWindowPlatformServices to it. It is available while the embedded window is open. A presentation without native dispatch, such as an installed browser after an embedded-window fallback, still has an owner, but its DesktopNativeOwner.IsAvailable is false. Under RUNIC_APPLICATION_SERVE_ONLY=1 the window has no presentation and so no owner; to bring a Window forward on any host and in either mode, use DesktopPlatformServices.PresentAsync, which reports PlatformUnavailableReason.OwnerUnavailable without one.
Surface
public DesktopSurface Surface { get; } The Desktop surface that hosts the window's web content.
Remarks
DesktopSurface.ExecuteJavaScriptAsync runs script in the connected View, for example from an in-process test.
ViewModel
public TViewModel ViewModel { get; } The window's scoped root ViewModel.
Window
public DesktopWindow Window { get; } The opened Desktop window.
Exceptions
InvalidOperationExceptionThe presentation has not opened yet.
Remarks
Under RUNIC_APPLICATION_SERVE_ONLY=1 the surface serves without a presentation.
Methods
CloseAsync
public ValueTask<RunicWindowCloseResult> CloseAsync(TimeSpan timeout, CancellationToken cancellationToken = default) Stops new operation admission and waits up to timeout for accepted work. At the timeout the visible window and its browser routes close promptly, while the host keeps its scope until the remaining operations finish. The first call selects the timeout; later calls return the same result.
Parameters
timeoutHow long accepted operations may run before the window closes anyway.
cancellationTokenStops this caller's wait. The close itself continues, and other callers still receive its result.
Exceptions
ArgumentOutOfRangeExceptiontimeoutis negative and not infinite.OperationCanceledExceptioncancellationTokenwas cancelled.
Documentation from IBridgeWindow.CloseAsync.
DisposeAsync
public ValueTask DisposeAsync() Closes the window immediately and waits until its resources are released.
WaitForCloseAsync
public ValueTask WaitForCloseAsync(CancellationToken cancellationToken = default) Completes when the window closes: the user closed it, or IBridgeWindow.CloseAsync or IAsyncDisposable.DisposeAsync started closing it. It does not release the window; dispose it afterwards.
Parameters
cancellationTokenStops the wait without closing the window.
Exceptions
OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
On macOS and with GTK 4 the process main thread must run DesktopEventLoop, which services the native window while the application awaits; RunicDesktopHost.Run does.
Documentation from IBridgeWindow.WaitForCloseAsync.