Skip to main content

ClassicDesktopStyleApplicationLifetime Class

Definition​

Assembly:Avalonia.Controls
Package:Avalonia
public class ClassicDesktopStyleApplicationLifetime

Inheritance: object -> ClassicDesktopStyleApplicationLifetime

Constructors​

NameDescription
ClassicDesktopStyleApplicationLifetimeNo summary available.

ClassicDesktopStyleApplicationLifetime Constructor​

public ClassicDesktopStyleApplicationLifetime()

Methods​

NameDescription
DisposeNo summary available.
ShutdownNo summary available.
Start (2 overloads)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.
TryShutdownNo summary available.

Dispose Method​

public void Dispose()

Shutdown Method​

public void Shutdown(int exitCode)

Parameters​

exitCode int

Start overloads​

Start Method​

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 Method​

public int Start(string[] args)
Parameters​

args string[]

Returns​

int

TryShutdown Method​

public bool TryShutdown(int exitCode)

Parameters​

exitCode int

Returns​

bool

Properties​

NameDescription
ArgsGets the arguments passed to the AppBuilder Start method.
MainWindowGets or sets the main window of the application.
ShutdownModeGets or sets the Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode. This property indicates whether the application is shutdown explicitly or implicitly. If Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode is set to OnExplicitShutdown the application is only closes if Shutdown is called. The default is OnLastWindowClose
WindowsGets the list of all open windows in the application.

Args Property​

Gets the arguments passed to the AppBuilder Start method.

public string[] Args { get; set; }

MainWindow Property​

Gets or sets the main window of the application.

public Avalonia.Controls.Window MainWindow { get; set; }

Value​

The main window.

ShutdownMode Property​

Gets or sets the Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode. This property indicates whether the application is shutdown explicitly or implicitly. If Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime.ShutdownMode is set to OnExplicitShutdown the application is only closes if Shutdown is called. The default is OnLastWindowClose

public Avalonia.Controls.ShutdownMode ShutdownMode { get; set; }

Value​

The shutdown mode.

Windows Property​

Gets the list of all open windows in the application.

public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Window> Windows { get; set; }

Events​

NameDescription
ExitSent when the application is exiting.
ShutdownRequestedRaised by the platform when an application shutdown is requested.
StartupSent when the application is starting up.

Exit Event​

Sent when the application is exiting.

public event EventHandler<Avalonia.Controls.ApplicationLifetimes.ControlledApplicationLifetimeExitEventArgs> Exit

ShutdownRequested Event​

Raised by the platform when an application shutdown is requested.

public event EventHandler<Avalonia.Controls.ApplicationLifetimes.ShutdownRequestedEventArgs> ShutdownRequested

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 Avalonia.Controls.Window.Closing event on each and allowing each window to cancel the shutdown of the application. Windows cannot however prevent OS shutdown.

Startup Event​

Sent when the application is starting up.

public event EventHandler<Avalonia.Controls.ApplicationLifetimes.ControlledApplicationLifetimeStartupEventArgs> Startup