<PackageReference Include="System.Reactive" Version="5.0.0-preview.16" />

Scheduler

public static class Scheduler
Provides a set of static properties to access commonly used schedulers.
public static CurrentThreadScheduler CurrentThread { get; }

Gets a scheduler that schedules work as soon as possible on the current thread.

public static DefaultScheduler Default { get; }

Gets a scheduler that schedules work on the platform's default scheduler.

public static ImmediateScheduler Immediate { get; }

Gets a scheduler that schedules work immediately on the current thread.

public static IScheduler NewThread { get; }

Gets a scheduler that schedules work on a new thread using default thread creation options.

public static DateTimeOffset Now { get; }

Gets the current time according to the local machine's system clock.

public static IScheduler TaskPool { get; }

Gets a scheduler that schedules work on Task Parallel Library (TPL) task pool using the default TaskScheduler.

public static IScheduler ThreadPool { get; }

Gets a scheduler that schedules work on the thread pool.

public static ISchedulerLongRunning AsLongRunning(this IScheduler scheduler)

Returns the ISchedulerLongRunning implementation of the specified scheduler, or null if no such implementation is available.

public static ISchedulerPeriodic AsPeriodic(this IScheduler scheduler)

Returns the ISchedulerPeriodic implementation of the specified scheduler, or null if no such implementation is available.

public static IStopwatchProvider AsStopwatchProvider(this IScheduler scheduler)

Returns the IStopwatchProvider implementation of the specified scheduler, or null if no such implementation is available.

public static IScheduler Catch<TException>(this IScheduler scheduler, Func<TException, bool> handler) where TException : Exception

Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.

public static IScheduler DisableOptimizations(this IScheduler scheduler)

Returns a scheduler that represents the original scheduler, without any of its interface-based optimizations (e.g. long running scheduling).

public static IScheduler DisableOptimizations(this IScheduler scheduler, Type[] optimizationInterfaces)

Returns a scheduler that represents the original scheduler, without the specified set of interface-based optimizations (e.g. long running scheduling).

public static TimeSpan Normalize(TimeSpan timeSpan)

Normalizes the specified TimeSpan value to a positive value.

public static IDisposable Schedule(this IScheduler scheduler, Action<Action> action)

Schedules an action to be executed recursively.

public static IDisposable Schedule<TState>(this IScheduler scheduler, TState state, Action<TState, Action<TState>> action)

Schedules an action to be executed recursively.

public static IDisposable Schedule(this IScheduler scheduler, TimeSpan dueTime, Action<Action<TimeSpan>> action)

Schedules an action to be executed recursively after a specified relative due time.

public static IDisposable Schedule<TState>(this IScheduler scheduler, TState state, TimeSpan dueTime, Action<TState, Action<TState, TimeSpan>> action)

Schedules an action to be executed recursively after a specified relative due time.

public static IDisposable Schedule(this IScheduler scheduler, DateTimeOffset dueTime, Action<Action<DateTimeOffset>> action)

Schedules an action to be executed recursively at a specified absolute due time.

public static IDisposable Schedule<TState>(this IScheduler scheduler, TState state, DateTimeOffset dueTime, Action<TState, Action<TState, DateTimeOffset>> action)

Schedules an action to be executed recursively at a specified absolute due time.

public static IDisposable Schedule(this IScheduler scheduler, Action action)

Schedules an action to be executed.

public static IDisposable Schedule(this IScheduler scheduler, TimeSpan dueTime, Action action)

Schedules an action to be executed after the specified relative due time.

public static IDisposable Schedule(this IScheduler scheduler, DateTimeOffset dueTime, Action action)

Schedules an action to be executed at the specified absolute due time.

public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, Func<IScheduler, TState, CancellationToken, Task> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, Func<IScheduler, TState, CancellationToken, Task<IDisposable>> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync(this IScheduler scheduler, Func<IScheduler, CancellationToken, Task> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, TimeSpan dueTime, Func<IScheduler, TState, CancellationToken, Task> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, TimeSpan dueTime, Func<IScheduler, TState, CancellationToken, Task<IDisposable>> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync(this IScheduler scheduler, TimeSpan dueTime, Func<IScheduler, CancellationToken, Task> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync(this IScheduler scheduler, TimeSpan dueTime, Func<IScheduler, CancellationToken, Task<IDisposable>> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, DateTimeOffset dueTime, Func<IScheduler, TState, CancellationToken, Task> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync<TState>(this IScheduler scheduler, TState state, DateTimeOffset dueTime, Func<IScheduler, TState, CancellationToken, Task<IDisposable>> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

public static IDisposable ScheduleAsync(this IScheduler scheduler, DateTimeOffset dueTime, Func<IScheduler, CancellationToken, Task> action)

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

Schedules work using an asynchronous method, allowing for cooperative scheduling in an imperative coding style.

Schedules an action to be executed.

public static IDisposable SchedulePeriodic<TState>(this IScheduler scheduler, TState state, TimeSpan period, Func<TState, TState> action)

Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. If the scheduler supports periodic scheduling, the request will be forwarded to the periodic scheduling implementation. If the scheduler provides stopwatch functionality, the periodic task will be emulated using recursive scheduling with a stopwatch to correct for time slippage. Otherwise, the periodic task will be emulated using recursive scheduling.

public static IDisposable SchedulePeriodic<TState>(this IScheduler scheduler, TState state, TimeSpan period, Action<TState> action)

Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. If the scheduler supports periodic scheduling, the request will be forwarded to the periodic scheduling implementation. If the scheduler provides stopwatch functionality, the periodic task will be emulated using recursive scheduling with a stopwatch to correct for time slippage. Otherwise, the periodic task will be emulated using recursive scheduling.

public static IDisposable SchedulePeriodic(this IScheduler scheduler, TimeSpan period, Action action)

Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. If the scheduler supports periodic scheduling, the request will be forwarded to the periodic scheduling implementation. If the scheduler provides stopwatch functionality, the periodic task will be emulated using recursive scheduling with a stopwatch to correct for time slippage. Otherwise, the periodic task will be emulated using recursive scheduling.

public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime)

Suspends execution of the current work item on the scheduler for the specified duration. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) after the specified duration.

public static SchedulerOperation Sleep(this IScheduler scheduler, TimeSpan dueTime, CancellationToken cancellationToken)

Suspends execution of the current work item on the scheduler for the specified duration. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) after the specified duration.

public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime)

Suspends execution of the current work item on the scheduler until the specified due time. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) at the specified due time.

public static SchedulerOperation Sleep(this IScheduler scheduler, DateTimeOffset dueTime, CancellationToken cancellationToken)

Suspends execution of the current work item on the scheduler until the specified due time. The caller should await the result of calling Sleep to schedule the remainder of the current work item (known as the continuation) at the specified due time.

public static IStopwatch StartStopwatch(this IScheduler scheduler)

Starts a new stopwatch object by dynamically discovering the scheduler's capabilities. If the scheduler provides stopwatch functionality, the request will be forwarded to the stopwatch provider implementation. Otherwise, the stopwatch will be emulated using the scheduler's notion of absolute time.

public static SchedulerOperation Yield(this IScheduler scheduler)

Yields execution of the current work item on the scheduler to another work item on the scheduler. The caller should await the result of calling Yield to schedule the remainder of the current work item (known as the continuation).

public static SchedulerOperation Yield(this IScheduler scheduler, CancellationToken cancellationToken)

Yields execution of the current work item on the scheduler to another work item on the scheduler. The caller should await the result of calling Yield to schedule the remainder of the current work item (known as the continuation).