# ClassicDesktopStyleApplicationLifetime

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/application_lifetimes/struct-classicdesktopstyleapplicationlifetime/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct ClassicDesktopStyleApplicationLifetime
```

The application lifetime of classic desktop applications: it tracks the
open windows, shuts the application down according to its
[`ShutdownMode`](/docs/0.5.0/api/ferroui-controls/enum-shutdownmode/) and runs the main loop where the platform has one.
## Ownership

The lifetime is a shared handle (`Rc`). Once it has been set up it is
kept alive by the window class handlers it registers, by the platform
lifetime events it subscribes to and by the application it is the
lifetime of (which the service locator holds), so nothing depends on the
stack frame of the caller of `start`. Call
`dispose` to release those subscriptions.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L28)

## Members

- [`new`](#function-new)
- [`startup`](#function-startup)
- [`shutdown_requested`](#function-shutdown_requested)
- [`exit`](#function-exit)
- [`args`](#function-args)
- [`set_args`](#function-set_args)
- [`shutdown_mode`](#function-shutdown_mode)
- [`set_shutdown_mode`](#function-set_shutdown_mode)
- [`main_window`](#function-main_window)
- [`set_main_window`](#function-set_main_window)
- [`windows`](#function-windows)
- [`shutdown`](#function-shutdown)
- [`try_shutdown`](#function-try_shutdown)
- [`start`](#function-start)
- [`start_with_own_args`](#function-start_with_own_args)
- [`dispose`](#function-dispose)

<a id="function-new"></a>

### new

```rust
fn new() -> Rc<Self>
```

Creates a lifetime without arguments, with the default shutdown mode
and without a main window.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L50)

<a id="function-startup"></a>

### startup

```rust
fn startup(self: &Self, handler: impl Fn(&ControlledApplicationLifetimeStartupEventArgs) -> () + 'static) -> Subscription
```

Raised when the application is starting. Dropping the returned guard removes the handler;
`Subscription::detach` keeps it for the life of the lifetime.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L91)

<a id="function-shutdown_requested"></a>

### shutdown_requested

```rust
fn shutdown_requested(self: &Self, handler: impl Fn(&ShutdownRequestedEventArgs) -> () + 'static) -> Subscription
```

Raised when an application shutdown is requested; see
`IClassicDesktopStyleApplicationLifetime::shutdown_requested`. Dropping the returned guard
removes the handler; `Subscription::detach` keeps it for the life of the lifetime.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L102)

<a id="function-exit"></a>

### exit

```rust
fn exit(self: &Self, handler: impl Fn(&ControlledApplicationLifetimeExitEventArgs) -> () + 'static) -> Subscription
```

Raised when the application is exiting. Dropping the returned guard removes the handler;
`Subscription::detach` keeps it for the life of the lifetime.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L109)

<a id="function-args"></a>

### args

```rust
fn args(self: &Self) -> Option<Vec<String>>
```

The arguments passed to the builder's start method.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L115)

<a id="function-set_args"></a>

### set_args

```rust
fn set_args(self: &Self, value: Option<Vec<String>>)
```

Sets the arguments of the application.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L120)

<a id="function-shutdown_mode"></a>

### shutdown_mode

```rust
fn shutdown_mode(self: &Self) -> ShutdownMode
```

The shutdown mode; see
`IClassicDesktopStyleApplicationLifetime::shutdown_mode`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L126)

<a id="function-set_shutdown_mode"></a>

### set_shutdown_mode

```rust
fn set_shutdown_mode(self: &Self, value: ShutdownMode)
```

Sets the shutdown mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L131)

<a id="function-main_window"></a>

### main_window

```rust
fn main_window(self: &Self) -> Option<Ref<Window>>
```

The main window of the application.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L136)

<a id="function-set_main_window"></a>

### set_main_window

```rust
fn set_main_window(self: &Self, value: Option<Ref<Window>>)
```

Sets the main window of the application.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L141)

<a id="function-windows"></a>

### windows

```rust
fn windows(self: &Self) -> Vec<Ref<Window>>
```

The list of all open windows in the application, in the order they
were opened.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L148)

<a id="function-shutdown"></a>

### shutdown

```rust
fn shutdown(self: &Self, exit_code: i32)
```

Shuts down the application and sets the exit code that is returned
to the operating system. Windows cannot cancel this shutdown and the
shutdown requested event is not raised.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L169)

<a id="function-try_shutdown"></a>

### try_shutdown

```rust
fn try_shutdown(self: &Self, exit_code: i32) -> bool
```

Tries to shut down the application; the shutdown requested event and
the closing event of the windows can cancel the shutdown. Returns
whether the application shuts down.
## Panics
Panics when the application is already shutting down.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L179)

<a id="function-start"></a>

### start

```rust
fn start(self: &Self, args: &[String]) -> i32
```

Starts the application: raises the startup event with `args` and
shows the main window, then

- where the dispatcher of the UI thread supports run loops
  (`Dispatcher::supports_run_loops`), runs the main loop until the
  application shuts down and returns the exit code of the shutdown;
- otherwise (platforms whose event loop is owned by the host, such
  as a browser) returns immediately with the exit code as it is at
  that moment: 0, or the code of a shutdown that happened while the
  main window was shown. The application keeps running, driven by
  the host; a later `shutdown` or
  `try_shutdown` closes the windows, raises the
  exit event (which carries the exit code) and shuts the dispatcher
  down exactly as it does on the platforms with a loop.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L255)

<a id="function-start_with_own_args"></a>

### start_with_own_args

```rust
fn start_with_own_args(self: &Self) -> i32
```

`start` with the arguments the lifetime was prepared
with (`args`), for integrating with hosts that manage
the lifetime themselves.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L262)

<a id="function-dispose"></a>

### dispose

```rust
fn dispose(self: &Self)
```

Stops tracking windows and listening to the platform's shutdown
requests.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/application_lifetimes/classic_desktop_style_application_lifetime.rs#L313)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`IApplicationLifetime`](/docs/0.5.0/api/ferroui-controls/application_lifetimes/trait-iapplicationlifetime/)
- [`IControlledApplicationLifetime`](/docs/0.5.0/api/ferroui-controls/application_lifetimes/trait-icontrolledapplicationlifetime/)
- [`IClassicDesktopStyleApplicationLifetime`](/docs/0.5.0/api/ferroui-controls/application_lifetimes/trait-iclassicdesktopstyleapplicationlifetime/)
- [`ISetupApplicationLifetime`](/docs/0.5.0/api/ferroui-controls/application_lifetimes/trait-isetupapplicationlifetime/)
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
