DesktopBridgeWindow<TViewModel> class

Namespace Runic.Application.Views.Desktop in Runic.Application.Views.Desktop 0.23.0

public sealed class DesktopBridgeWindow<TViewModel> : IBridgeWindow, IAsyncDisposable where TViewModel : class

Inherits or implements IBridgeWindow, IAsyncDisposable.

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

InvalidOperationException

The 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

InvalidOperationException

The 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

timeout

How long accepted operations may run before the window closes anyway.

cancellationToken

Stops this caller's wait. The close itself continues, and other callers still receive its result.

Exceptions

ArgumentOutOfRangeException

timeout is negative and not infinite.

OperationCanceledException

cancellationToken was 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

cancellationToken

Stops the wait without closing the window.

Exceptions

OperationCanceledException

cancellationToken was 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.