# SchedulerExt

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive/concurrency/trait-schedulerext/

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

```rust
trait SchedulerExt
```

The extension methods of `Scheduler` on a scheduler (`Scheduler.Simple.cs`,
`Scheduler.Recursive.cs`, `Scheduler.Services.cs`, `Scheduler.Async.cs`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L106)

## Members

- [`schedule_action`](#function-schedule_action)
- [`schedule_action_after`](#function-schedule_action_after)
- [`schedule_action_at`](#function-schedule_action_at)
- [`schedule_recursive`](#function-schedule_recursive)
- [`schedule_recursive_with`](#function-schedule_recursive_with)
- [`schedule_recursive_after`](#function-schedule_recursive_after)
- [`schedule_recursive_after_with`](#function-schedule_recursive_after_with)
- [`schedule_recursive_at`](#function-schedule_recursive_at)
- [`schedule_periodic_action`](#function-schedule_periodic_action)
- [`start_stopwatch`](#function-start_stopwatch)
- [`disable_optimizations`](#function-disable_optimizations)
- [`disable_optimizations_of`](#function-disable_optimizations_of)
- [`schedule_async`](#function-schedule_async)
- [`schedule_async_with`](#function-schedule_async_with)
- [`schedule_async_after`](#function-schedule_async_after)
- [`schedule_async_after_with`](#function-schedule_async_after_with)
- [`schedule_async_at`](#function-schedule_async_at)
- [`schedule_async_at_with`](#function-schedule_async_at_with)
- [`yield_`](#function-yield_)
- [`yield_with_token`](#function-yield_with_token)
- [`sleep`](#function-sleep)
- [`sleep_with_token`](#function-sleep_with_token)
- [`sleep_at`](#function-sleep_at)
- [`sleep_at_with_token`](#function-sleep_at_with_token)

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

### schedule_action

```rust
fn schedule_action(self: &Self, action: impl FnOnce() -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action to run as soon as possible (`Schedule(Action)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L108)

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

### schedule_action_after

```rust
fn schedule_action_after(self: &Self, due_time: Duration, action: impl FnOnce() -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action to run after `due_time` (`Schedule(TimeSpan, Action)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L111)

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

### schedule_action_at

```rust
fn schedule_action_at(self: &Self, due_time: SystemTime, action: impl FnOnce() -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action to run at `due_time` (`Schedule(DateTimeOffset, Action)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L114)

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

### schedule_recursive

```rust
fn schedule_recursive(self: &Self, action: impl Fn(&dyn Fn() -> ()) -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action that can schedule itself again (`Schedule(Action<Action>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L117)

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

### schedule_recursive_with

```rust
fn schedule_recursive_with<S: 'static>(self: &Self, state: S, action: impl Fn(S, &dyn Fn(S) -> ()) -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action with a state that can schedule itself again with a new state
(`Schedule<TState>(TState, Action<TState, Action<TState>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L121)

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

### schedule_recursive_after

```rust
fn schedule_recursive_after(self: &Self, due_time: Duration, action: impl Fn(&dyn Fn(Duration) -> ()) -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action after `due_time` that can schedule itself again after a time it chooses
(`Schedule(TimeSpan, Action<Action<TimeSpan>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L125)

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

### schedule_recursive_after_with

```rust
fn schedule_recursive_after_with<S: 'static>(self: &Self, state: S, due_time: Duration, action: impl Fn(S, &dyn Fn(S, Duration) -> ()) -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action with a state after `due_time` that can schedule itself again with a new
state after a time it chooses (`Schedule<TState>(TState, TimeSpan, Action<TState, Action<TState, TimeSpan>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L129)

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

### schedule_recursive_at

```rust
fn schedule_recursive_at(self: &Self, due_time: SystemTime, action: impl Fn(&dyn Fn(SystemTime) -> ()) -> () + 'static) -> Rc<dyn IDisposable>
```

Schedules an action at `due_time` that can schedule itself again at a time it chooses
(`Schedule(DateTimeOffset, Action<Action<DateTimeOffset>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L138)

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

### schedule_periodic_action

```rust
fn schedule_periodic_action(self: &Self, period: Duration, action: impl FnMut() -> () + 'static) -> Rc<dyn IDisposable>
```

Runs `action` every `period` (`SchedulePeriodic(TimeSpan, Action)`): through the periodic
scheduling of the scheduler if it has its own, else emulated with recursive scheduling.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L142)

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

### start_stopwatch

```rust
fn start_stopwatch(self: &Self) -> Box<dyn IStopwatch>
```

Starts a stopwatch (`StartStopwatch`): the scheduler's own if it has one, else one that
measures with the scheduler's clock.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L146)

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

### disable_optimizations

```rust
fn disable_optimizations(self: &Self) -> Rc<dyn IScheduler>
```

The scheduler without the services it offers (`DisableOptimizations(IScheduler)`): it
schedules on this one, answers none of the services of
`SchedulerOptimization::ALL`, and
hands the work it runs a scheduler without them too, so that operators use the emulated
forms (periodic scheduling through recursive scheduling, a stopwatch on the clock).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L153)

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

### disable_optimizations_of

```rust
fn disable_optimizations_of(self: &Self, optimizations: &[super::SchedulerOptimization]) -> Rc<dyn IScheduler>
```

The scheduler without the services `optimizations` (`DisableOptimizations(IScheduler,
params Type[])`): the other services are those of this one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L157)

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

### schedule_async

```rust
fn schedule_async<R: ScheduleAsyncResult, Fut: Future<Output = Result<R, ObservableError>> + 'static>(self: &Self, action: impl FnOnce(Rc<dyn IScheduler>, CancellationToken) -> Fut + 'static) -> Rc<dyn IDisposable>
```

Runs an asynchronous body on the scheduler, as soon as possible
(`ScheduleAsync(Func<IScheduler, CancellationToken, Task>)`,
`ScheduleAsync(Func<IScheduler, CancellationToken, Task<IDisposable>>)`).

The body receives a scheduler and a token. It runs on the scheduler, as a task of the thread,
until its first await; awaiting `yield_` or `sleep` of the
scheduler it received resumes it there. Disposing the result cancels the token, which ends a
pending `yield_` or `sleep` with a cancellation (`Canceled`), and disposes the disposable the body
ended with (its future's output: `()`, or an `Rc<dyn IDisposable>`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L168)

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

### schedule_async_with

```rust
fn schedule_async_with<S: 'static, R: ScheduleAsyncResult, Fut: Future<Output = Result<R, ObservableError>> + 'static>(self: &Self, state: S, action: impl FnOnce(Rc<dyn IScheduler>, S, CancellationToken) -> Fut + 'static) -> Rc<dyn IDisposable>
```

`schedule_async` with a state handed to the body
(`ScheduleAsync<TState>(TState, Func<IScheduler, TState, CancellationToken, Task>)`, and its
`Task<IDisposable>` form).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L176)

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

### schedule_async_after

```rust
fn schedule_async_after<R: ScheduleAsyncResult, Fut: Future<Output = Result<R, ObservableError>> + 'static>(self: &Self, due_time: Duration, action: impl FnOnce(Rc<dyn IScheduler>, CancellationToken) -> Fut + 'static) -> Rc<dyn IDisposable>
```

`schedule_async` after `due_time`
(`ScheduleAsync(TimeSpan, Func<IScheduler, CancellationToken, Task>)`, and its
`Task<IDisposable>` form).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L185)

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

### schedule_async_after_with

```rust
fn schedule_async_after_with<S: 'static, R: ScheduleAsyncResult, Fut: Future<Output = Result<R, ObservableError>> + 'static>(self: &Self, state: S, due_time: Duration, action: impl FnOnce(Rc<dyn IScheduler>, S, CancellationToken) -> Fut + 'static) -> Rc<dyn IDisposable>
```

`schedule_async_with` after `due_time`
(`ScheduleAsync<TState>(TState, TimeSpan, Func<IScheduler, TState, CancellationToken, Task>)`,
and its `Task<IDisposable>` form).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L194)

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

### schedule_async_at

```rust
fn schedule_async_at<R: ScheduleAsyncResult, Fut: Future<Output = Result<R, ObservableError>> + 'static>(self: &Self, due_time: SystemTime, action: impl FnOnce(Rc<dyn IScheduler>, CancellationToken) -> Fut + 'static) -> Rc<dyn IDisposable>
```

`schedule_async` at `due_time`
(`ScheduleAsync(DateTimeOffset, Func<IScheduler, CancellationToken, Task>)`, and its
`Task<IDisposable>` form).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L204)

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

### schedule_async_at_with

```rust
fn schedule_async_at_with<S: 'static, R: ScheduleAsyncResult, Fut: Future<Output = Result<R, ObservableError>> + 'static>(self: &Self, state: S, due_time: SystemTime, action: impl FnOnce(Rc<dyn IScheduler>, S, CancellationToken) -> Fut + 'static) -> Rc<dyn IDisposable>
```

`schedule_async_with` at `due_time`
(`ScheduleAsync<TState>(TState, DateTimeOffset, Func<IScheduler, TState, CancellationToken, Task>)`,
and its `Task<IDisposable>` form).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L213)

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

### yield_

```rust
fn yield_(self: &Self) -> SchedulerOperation
```

An operation whose await hands the rest of the work to the scheduler, to run after the work
queued before it (`Yield(IScheduler)`); on the scheduler of a
`schedule_async` body, the token of the body cancels it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L223)

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

### yield_with_token

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

`yield_` that the cancellation of `token` ends with a cancellation
(`Canceled`; `Yield(IScheduler, CancellationToken)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L227)

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

### sleep

```rust
fn sleep(self: &Self, due_time: Duration) -> SchedulerOperation
```

An operation whose await runs the rest of the work on the scheduler after `due_time`
(`Sleep(IScheduler, TimeSpan)`); on the scheduler of a
`schedule_async` body, the token of the body cancels it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L232)

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

### sleep_with_token

```rust
fn sleep_with_token(self: &Self, due_time: Duration, token: CancellationToken) -> SchedulerOperation
```

`sleep` that the cancellation of `token` ends with a cancellation
(`Canceled`; `Sleep(IScheduler, TimeSpan, CancellationToken)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L236)

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

### sleep_at

```rust
fn sleep_at(self: &Self, due_time: SystemTime) -> SchedulerOperation
```

An operation whose await runs the rest of the work on the scheduler at `due_time`
(`Sleep(IScheduler, DateTimeOffset)`); on the scheduler of a
`schedule_async` body, the token of the body cancels it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L241)

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

### sleep_at_with_token

```rust
fn sleep_at_with_token(self: &Self, due_time: SystemTime, token: CancellationToken) -> SchedulerOperation
```

`sleep_at` that the cancellation of `token` ends with a cancellation
(`Canceled`; `Sleep(IScheduler, DateTimeOffset, CancellationToken)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/scheduler.rs#L245)

## Trait implementations

- [`SchedulerExt`](/docs/0.5.0/api/ferroui-reactive/concurrency/trait-schedulerext/)

## Availability

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