Documentation
On this page

Interface · Application Lifecycle

DesktopApplication

Desktop application lifetime and window manager.

@sharpts/gui · SharpTS 572a2e31be0e

Members

isDisposed

readonly isDisposed: boolean

Whether the application lifetime has been disposed.

Type: boolean

windowCount

readonly windowCount: number

Number of currently open application windows.

Type: number

createTrayIcon

createTrayIcon(options: TrayIconOptions): DesktopTrayIcon

Creates a native system tray icon.

Remarks

The application owns the icon, but callers should dispose it as soon as it is no longer needed.

Throws

  • When the application is disposed or the icon or menu configuration is invalid.

Examples

TypeScript
const tray = app.createTrayIcon({ icon: "assets/app.ico", toolTip: "SharpTS" });

createWindow

createWindow(element: GuiChild, options?: DesktopWindowOptions): DesktopWindow

Creates and synchronously performs the initial render of a native window.

Remarks

Await the window's closed promise when later work depends on its lifetime, and dispose the application when it is no longer needed.

Throws

  • When the application is disposed, the owner belongs to another application, or the initial render fails.

Examples

TypeScript
const window = app.createWindow(<Window title="Dashboard" />);

dispose

dispose(): void

Disposes all windows, tray icons, and application resources.

Remarks

Disposing the application is terminal; create a new application lifetime to open more windows.

Examples

TypeScript
app.dispose();

shutdown

shutdown(exitCode?: number): void

Ends the desktop message loop with an optional process exit code.

Remarks

Shutdown requests loop termination; dispose remains responsible for releasing application resources.

Examples

TypeScript
app.shutdown(0);

Source

src/SharpTS.Gui.Sdk/GuiPackage/runtime.ts:1134 at SharpTS revision 572a2e31be0e2a09be0138bc44501b34d6245b51.