public sealed class DesktopWindow : IAsyncDisposable Represents one installed-browser or embedded-WebView presentation of a surface.
Properties
Browser
public BrowserKind Browser { get; } Gets the presentation that opened.
Remarks
For a BrowserKind.Any or BrowserKind.ChromiumBased request this is the concrete browser that was launched, or BrowserKind.Any when it could not be identified.
Capabilities
public DesktopWindowCapabilities Capabilities { get; } Gets the platform-window operations the open window supports.
Remarks
Only embedded windows report capabilities; installed browsers and closed windows report DesktopWindowCapabilities.None.
FellBack
public bool FellBack { get; } Gets whether the embedded WebView was unavailable and the browser fallback opened instead.
IsOpen
public bool IsOpen { get; } Gets whether this is the surface's current window and its browser process or embedded window is still open.
NativeHandle
public nint NativeHandle { get; } Gets the native top-level handle of an open embedded window, or zero for an installed browser or closed window.
ProcessId
public ulong ProcessId { get; } Gets the installed browser's process identifier, or zero for an embedded or closed window.
RequestedBrowser
public BrowserKind RequestedBrowser { get; } Gets the presentation requested by DesktopWindowOptions.Browser.
SupportsNativeDispatch
public bool SupportsNativeDispatch { get; } Whether this live embedded owner supports native-thread callbacks.
Methods
CheckNativeAccess
public bool CheckNativeAccess() Whether the caller is executing on the live native owner's thread.
CloseAsync
public ValueTask CloseAsync() Forcibly closes this window without awaiting confirmation. Use RequestCloseAsync for user actions.
DispatchNativeAsync
public ValueTask DispatchNativeAsync(Action<nint> action, CancellationToken cancellationToken = default) Runs native work on this owner's thread. Cancellation prevents queued work; a running callback is awaited to completion. No native handle may outlive this window.
DisposeAsync
public ValueTask DisposeAsync() Forcibly closes the window, like DesktopWindow.CloseAsync.
FocusAsync
public Task FocusAsync(CancellationToken cancellationToken = default) Activates the window and gives it keyboard focus.
Parameters
cancellationTokenCancels waiting for the window and the queued native operation.
Returns
A task that completes when the window has been focused.
Exceptions
ObjectDisposedExceptionThe surface is disposed, or this window is closed or was replaced.
DesktopExceptionThe window lacks the required capability (
window-capability-unavailable).OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
Requires DesktopWindowCapabilities.Focus.
MinimizeAsync
public Task MinimizeAsync(CancellationToken cancellationToken = default) Minimizes the window.
Parameters
cancellationTokenCancels waiting for the window and the queued native operation.
Returns
A task that completes when the window has been minimized.
Exceptions
ObjectDisposedExceptionThe surface is disposed, or this window is closed or was replaced.
DesktopExceptionThe window lacks the required capability (
window-capability-unavailable).OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
Requires DesktopWindowCapabilities.Minimize.
MoveAsync
public ValueTask MoveAsync(uint x, uint y, CancellationToken cancellationToken = default) Moves the window to a screen position.
Parameters
xThe new horizontal position in pixels.
yThe new vertical position in pixels.
cancellationTokenCancels waiting for the window and the queued native operation.
Returns
A task that completes when the window has been moved.
Exceptions
ObjectDisposedExceptionThe surface is disposed, or this window is closed or was replaced.
DesktopExceptionThe window lacks the required capability (
window-capability-unavailable).OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
Requires DesktopWindowCapabilities.Move.
RequestCloseAsync
public ValueTask<bool> RequestCloseAsync(CancellationToken cancellationToken = default) Requests closing, awaiting the same confirmation as the native close button.
Remarks
Cancelling the caller stops its wait, without cancelling another caller's shared decision.
ResizeAsync
public ValueTask ResizeAsync(uint width, uint height, CancellationToken cancellationToken = default) Resizes the window.
Parameters
widthThe new width in pixels.
heightThe new height in pixels.
cancellationTokenCancels waiting for the window and the queued native operation.
Returns
A task that completes when the window has been resized.
Exceptions
ObjectDisposedExceptionThe surface is disposed, or this window is closed or was replaced.
DesktopExceptionThe window lacks the required capability (
window-capability-unavailable).OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
Requires DesktopWindowCapabilities.Resize.
ToggleMaximizedAsync
public Task ToggleMaximizedAsync(CancellationToken cancellationToken = default) Maximizes the window, or restores it when it is already maximized.
Parameters
cancellationTokenCancels waiting for the window and the queued native operation.
Returns
A task that completes when the window state has changed.
Exceptions
ObjectDisposedExceptionThe surface is disposed, or this window is closed or was replaced.
DesktopExceptionThe window lacks the required capability (
window-capability-unavailable).OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
Requires DesktopWindowCapabilities.Maximize.
WaitForClose
public void WaitForClose(CancellationToken cancellationToken = default) Blocks until this presentation closes while servicing platform window events.