# TaskCompletionSource

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/threading/tasks/struct-taskcompletionsource/

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

```rust
struct TaskCompletionSource<T>
```

The producer side of a task that code ends by hand (`TaskCompletionSource<TResult>`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L326)

> **Deprecated since 0.5.0.** use `ferroui_system::task::oneshot::channel` (a sender of a `Result`; dropping it cancels), or `Shared::channel` for synchronous continuations

## Members

- [`new`](#function-new)
- [`task`](#function-task)
- [`set_result`](#function-set_result)
- [`try_set_result`](#function-try_set_result)
- [`set_exception`](#function-set_exception)
- [`try_set_exception`](#function-try_set_exception)
- [`set_canceled`](#function-set_canceled)
- [`try_set_canceled`](#function-try_set_canceled)

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

### new

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

A source with a task that has not ended.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L344)

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

### task

```rust
fn task(self: &Self) -> Task<T>
```

The task of the source (`Task`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L349)

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

### set_result

```rust
fn set_result(self: &Self, result: T)
```

Ends the task with `result` (`SetResult`).
## Panics
When the task has ended (`InvalidOperationException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L357)

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

### try_set_result

```rust
fn try_set_result(self: &Self, result: T) -> bool
```

Ends the task with `result` unless it has ended (`TrySetResult`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L362)

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

### set_exception

```rust
fn set_exception(self: &Self, error: ObservableError)
```

Ends the task with `error` (`SetException`); a cancellation (`Canceled`,
`TaskCanceledError`) cancels it.
## Panics
When the task has ended (`InvalidOperationException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L371)

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

### try_set_exception

```rust
fn try_set_exception(self: &Self, error: ObservableError) -> bool
```

Ends the task with `error` unless it has ended (`TrySetException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L376)

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

### set_canceled

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

Cancels the task (`SetCanceled`).
## Panics
When the task has ended (`InvalidOperationException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L384)

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

### try_set_canceled

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

Cancels the task unless it has ended (`TrySetCanceled`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/tasks/task.rs#L389)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `From<TaskCompletionSource<T>>`
- `Default`
- `Clone`

## Availability

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