# TaskHandle

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-xaml-interactions/struct-taskhandle/

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

```rust
struct TaskHandle<T: 'static>
```

A task of the dispatcher of the user interface, held as an untyped value (`Task<T>`): its
`JoinHandle`, shared.

Clones refer to the same task and compare equal. Awaiting a handle gives the outcome of the
task: its output, or a `JoinError` (`Panicked` when the future panicked, a value, not raised
again; `Canceled` when the task was aborted or the dispatcher shut down). Any number of clones
may await it; the output is taken by the first, the others get the failure or the
cancellation again, and `()` again for a task without a value.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L121)

## Members

- [`spawn`](#function-spawn)
- [`from_handle`](#function-from_handle)
- [`from_task`](#function-from_task)
- [`is_completed`](#function-is_completed)
- [`is_completed_successfully`](#function-is_completed_successfully)
- [`is_faulted`](#function-is_faulted)
- [`is_canceled`](#function-is_canceled)
- [`abort`](#function-abort)
- [`completed`](#function-completed)

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

### spawn

```rust
fn spawn<Fut>(future: Fut) -> Self
where Fut: Future<Output = T> + 'static
```

Runs `future` on the dispatcher of the user interface and returns its task
(`Dispatcher.UIThread.InvokeAsync(async () => ..)`). The future starts in a job of the
dispatcher at `DispatcherPriority::DEFAULT`.
## Panics
Panics when called from a thread other than the thread of the user interface.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L136)

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

### from_handle

```rust
fn from_handle(handle: JoinHandle<T>) -> Self
```

The task of the handle of a task of the dispatcher.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L144)

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

### from_task

```rust
fn from_task(task: DispatcherTask<T>) -> Self
```

The task of an existing dispatcher task.

Deprecated: the task of the handle of a task of the dispatcher is
`from_handle` (`From`); the `DispatcherTask` converts into a
`JoinHandle` (on the dispatcher thread).

> **Deprecated since 0.5.0.** use `TaskHandle::from_handle` with a `JoinHandle` (`DispatcherTask` converts into one)

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L159)

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

### is_completed

```rust
fn is_completed(self: &Self) -> bool
```

Whether the task has finished: completed, failed or canceled (`IsCompleted`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L181)

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

### is_completed_successfully

```rust
fn is_completed_successfully(self: &Self) -> bool
```

Whether the task ran to the end (`IsCompletedSuccessfully`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L186)

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

### is_faulted

```rust
fn is_faulted(self: &Self) -> bool
```

Whether the future of the task panicked (`IsFaulted`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L191)

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

### is_canceled

```rust
fn is_canceled(self: &Self) -> bool
```

Whether the task was canceled (`IsCanceled`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L196)

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

### abort

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

Aborts the task, unless it has ended: its future is dropped, and it ends canceled.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L201)

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

### completed

```rust
fn completed() -> Self
```

A task that has already completed (`Task.CompletedTask`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactions/action_task.rs#L212)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `IntoFuture`
- `ToOwned`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `From<JoinHandle<T>>`
- `Clone`
- `PartialEq`
- `Debug`
- `Future`

## Availability

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