# CancellationTokenSource

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

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

```rust
struct CancellationTokenSource
```

Signals to one or more [`CancellationToken`](/docs/0.5.0/api/ferroui-system/threading/struct-cancellationtoken/)s that they should be canceled.

A source is a [`CancellationToken`](/docs/0.5.0/api/ferroui-system/threading/struct-cancellationtoken/) that can be canceled (`CancellationToken::new`): its
`token` is a clone of it, and canceling either cancels both.

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

> **Deprecated since 0.5.0.** use `CancellationToken::new()`, which can be canceled, and its clones in the place of `token()`

## Members

- [`new`](#function-new)
- [`token`](#function-token)
- [`is_cancellation_requested`](#function-is_cancellation_requested)
- [`cancel`](#function-cancel)

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

### new

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



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

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

### token

```rust
fn token(self: &Self) -> CancellationToken
```

The token observing this source.

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

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

### is_cancellation_requested

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



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

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

### cancel

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

Requests cancellation and runs the registered callbacks on the
calling thread. Subsequent calls do nothing.

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

## Trait implementations

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

## Availability

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