# AutoSuspendHelper

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui-controls/struct-autosuspendhelper/

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

```rust
struct AutoSuspendHelper
```

Automatic suspension and state persistence for FerroUI applications (`AutoSuspendHelper`).

Pass the application's lifetime object to `new`, and call
`on_framework_initialization_completed` from the
application's `on_framework_initialization_completed` to signal the launch. The helper connects
ReactiveUI's suspension host (`RxSuspension`) to the exit of the application and to unhandled
errors. It does not persist state in design mode.

Deviation (DEVIATIONS.md, ReactiveUI controls): the helper is shared (`Rc`), and released with
`dispose`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/auto_suspend_helper.rs#L25)

## Members

- [`new`](#function-new)
- [`on_framework_initialization_completed`](#function-on_framework_initialization_completed)
- [`on_unhandled_exception`](#function-on_unhandled_exception)

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

### new

```rust
fn new(lifetime: Option<&dyn IApplicationLifetime>) -> Rc<Self>
```

Connects the suspension host to `lifetime` (`AutoSuspendHelper(IApplicationLifetime)`).

In design mode, state persistence is disabled. A controlled lifetime has its exit wired to
the persistence of the state. Call it after the application is initialized.
## Panics
When `lifetime` is `None` (`ArgumentNullException`), and when the lifetime is not a
controlled one, whose exit the helper cannot detect (`NotSupportedException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/auto_suspend_helper.rs#L49)

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

### on_framework_initialization_completed

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

Signals that the framework initialization has completed
(`OnFrameworkInitializationCompleted`): notifies the launch of the application.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/auto_suspend_helper.rs#L90)

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

### on_unhandled_exception

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

Invalidates the persisted state after an unhandled error (`OnUnhandledException`).

Deviation (DEVIATIONS.md, ReactiveUI controls): upstream subscribes to
`AppDomain.UnhandledException`; Rust has no such event of the process, so the application
calls this method where it handles a failure (a panic hook, the handler of a dispatcher).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/auto_suspend_helper.rs#L99)

## 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`
- [`IEnableLogger`](/docs/0.5.0/api/ferroui-splat/logging/trait-ienablelogger/)
- [`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/).
