public interface IRunicWindow : IRunicView, IAsyncDisposable An application Window that any host can open. RunicWindow implements it.
Remarks
Only RunicWindow can implement this interface.
Properties
Host
IBridgeWindow Host { get; } The host adapter of the open window, such as DesktopBridgeWindow<TViewModel>.
Exceptions
InvalidOperationExceptionThe window has not opened.
Presentation
IRunicWindowPresentation Presentation { get; } The Window as it appears on the desktop: bring it to the front, minimize, hide or show it, and read whether it is active, from code outside its scope, such as a status icon's handler. Its ViewModel takes the same object as IRunicWindowPresentation.
Remarks
Readable before the Window opens and after it closes; its requests then report PlatformUnavailableReason.OwnerUnavailable or PlatformUnavailableReason.OwnerClosed.
Documentation from RunicWindow.Presentation.
Services
IServiceProvider Services { get; } The services of the window's dependency injection scope, which resolved RunicWindow.ViewModel. Scoped services resolved here are the ones the window's ViewModels received.
Exceptions
InvalidOperationExceptionThe window has not started opening.
Remarks
The window's host disposes the scope when the window is released; resolving from it after that throws ObjectDisposedException. A test reads the scoped services of a window it opened:
await using var window = await host.OpenWindowAsync<MainWindow>();
var documents = window.Services.GetRequiredService<DocumentStore>();Documentation from RunicWindow.Services.
Methods
CloseAsync
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.
RequestCloseAsync
ValueTask<bool> RequestCloseAsync(CancellationToken cancellationToken = default) Asks to close the window as the user's close button does, like Window.Close() in WPF and Avalonia, and returns whether it closed. With RunicWindow.GuardClose it first asks RunicWindow.CanCloseAsync, and returns false with the window open when that does; without it the window closes.
Parameters
cancellationTokenStops this caller's wait; the decision continues for other requests.
Returns
true when the window closed; false when it stays open.
Exceptions
InvalidOperationExceptionThe window has not opened.
OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
A request while another request or a user close is being decided waits for the same decision. When the window may close, its visible window closes at once, and accepted operations finish before RunicWindow.DisposeAsync releases its scope, as after a user close. On Runic Desktop's embedded window the request is the native close request, so a DesktopWindowOptions.ConfirmCloseAsync of the host is asked too. On CS-WebUI and in a browser, where the user's close cannot be guarded, this request still is.
Use RunicWindow.CloseAsync to close without asking, for example after the application has already decided. A closed window returns true.
Documentation from RunicWindow.RequestCloseAsync.
WaitForCloseAsync
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.
Documentation from IBridgeWindow.WaitForCloseAsync.