Interface IClassicDesktopStyleApplicationLifetime
- Namespace
- Avalonia.Controls.ApplicationLifetimes
- Assembly
- Avalonia.Controls.dll
Controls application lifetime in classic desktop style
[NotClientImplementable]
public interface IClassicDesktopStyleApplicationLifetime : IControlledApplicationLifetime, IApplicationLifetime
- Inherited Members
Properties
Args
Gets the arguments passed to the StartWithClassicDesktopLifetime(AppBuilder, string[], ShutdownMode) method.
string[]? Args { get; }
Property Value
- string[]
MainWindow
Gets or sets the main window of the application.
Window? MainWindow { get; set; }
Property Value
- Window
The main window.
ShutdownMode
Gets or sets the ShutdownMode. This property indicates whether the application is shutdown explicitly or implicitly. If ShutdownMode is set to OnExplicitShutdown the application is only closes if Shutdown is called. The default is OnLastWindowClose
ShutdownMode ShutdownMode { get; set; }
Property Value
- ShutdownMode
The shutdown mode.
Windows
Gets the list of all open windows in the application.
IReadOnlyList<Window> Windows { get; }
Property Value
Methods
TryShutdown(int)
Tries to Shutdown the application. ShutdownRequested event can be used to cancel the shutdown.
bool TryShutdown(int exitCode = 0)
Parameters
exitCode
intAn integer exit code for an application. The default exit code is 0.
Returns
Events
ShutdownRequested
Raised by the platform when an application shutdown is requested.
event EventHandler<ShutdownRequestedEventArgs>? ShutdownRequested
Event Type
Remarks
Application Shutdown can be requested for various reasons like OS shutdown.
On Windows this will be called when an OS Session (logout or shutdown) terminates. Cancelling the eventargs will block OS shutdown.
On OSX this has the same behavior as on Windows and in addition: This event is raised via the Quit menu or right-clicking on the application icon and selecting Quit.
This event provides a first-chance to cancel application shutdown; if shutdown is not canceled at this point the application will try to close each non-owned open window, invoking the Closing event on each and allowing each window to cancel the shutdown of the application. Windows cannot however prevent OS shutdown.