Class ClassicDesktopStyleApplicationLifetime
- Namespace
- Avalonia.Controls.ApplicationLifetimes
- Assembly
- Avalonia.Controls.dll
public class ClassicDesktopStyleApplicationLifetime : IClassicDesktopStyleApplicationLifetime, IControlledApplicationLifetime, IApplicationLifetime, IDisposable
- Inheritance
-
ClassicDesktopStyleApplicationLifetime
- Implements
- Inherited Members
Constructors
ClassicDesktopStyleApplicationLifetime()
public ClassicDesktopStyleApplicationLifetime()
Properties
Args
Gets the arguments passed to the AppBuilder Start method.
public string[]? Args { get; set; }
Property Value
- string[]
MainWindow
Gets or sets the main window of the application.
public 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
public ShutdownMode ShutdownMode { get; set; }
Property Value
- ShutdownMode
The shutdown mode.
Windows
Gets the list of all open windows in the application.
public IReadOnlyList<Window> Windows { get; }
Property Value
Methods
Dispose()
public void Dispose()
Shutdown(int)
Shuts down the application and sets the exit code that is returned to the operating system when the application exits.
public void Shutdown(int exitCode = 0)
Parameters
exitCode
intAn integer exit code for an application. The default exit code is 0.
Start()
Since the lifetime must be set up/prepared with 'args' before executing Start(), an overload with no parameters seems more suitable for integrating with some lifetime manager providers, such as MS HostApplicationBuilder.
public int Start()
Returns
- int
exit code
Start(string[])
public int Start(string[] args)
Parameters
args
string[]
Returns
TryShutdown(int)
Tries to Shutdown the application. ShutdownRequested event can be used to cancel the shutdown.
public bool TryShutdown(int exitCode = 0)
Parameters
exitCode
intAn integer exit code for an application. The default exit code is 0.
Returns
Events
Exit
Sent when the application is exiting.
public event EventHandler<ControlledApplicationLifetimeExitEventArgs>? Exit
Event Type
ShutdownRequested
Raised by the platform when an application shutdown is requested.
public 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.
Startup
Sent when the application is starting up.
public event EventHandler<ControlledApplicationLifetimeStartupEventArgs>? Startup