Scheduler Class

The scheduler of a window or of a worker (https://wicg.github.io/scheduling-apis/#sec-scheduler, see GlobalScope.Scheduler): it posts prioritized tasks to the event loop. The tasks of all the schedulers of an event loop run in the order of their priorities (TaskPriority), then in the order they were queued; a continuation (Scheduler.Yield) runs before the tasks of its priority.

public sealed class Scheduler

Methods

NameDescription
PostTask(SchedulerPostTaskCallback, SchedulerPostTaskOptions?)Posts a task that calls callback (https://wicg.github.io/scheduling-apis/#dom-scheduler-posttask). The returned task is completed with the result of the callback (when the caller is a script and the result is a promise, with its settlement), fails with the exception the callback throws, or with the abort reason of the signal of the options when it is aborted before the callback runs.
Yield()Yields to the event loop (https://wicg.github.io/scheduling-apis/#dom-scheduler-yield): the returned task is completed by a continuation, which runs before the tasks of its priority. In a task posted with Scheduler.PostTask (and in its continuations), the continuation inherits the priority and the signal of the task: it fails with the abort reason when the signal is aborted. Otherwise its priority is TaskPriority.UserVisible.

PostTask(SchedulerPostTaskCallback, SchedulerPostTaskOptions?)

Scheduler.cs

Posts a task that calls callback (https://wicg.github.io/scheduling-apis/#dom-scheduler-posttask). The returned task is completed with the result of the callback (when the caller is a script and the result is a promise, with its settlement), fails with the exception the callback throws, or with the abort reason of the signal of the options when it is aborted before the callback runs.

public Task<object?> PostTask(SchedulerPostTaskCallback callback, SchedulerPostTaskOptions? options = null)

Parameters

callback SchedulerPostTaskCallback
The callback of the task.
options SchedulerPostTaskOptions?
The signal, the priority and the delay of the task, or null.

Returns

Task<object?>

See also

Yields to the event loop (https://wicg.github.io/scheduling-apis/#dom-scheduler-yield): the returned task is completed by a continuation, which runs before the tasks of its priority. In a task posted with Scheduler.PostTask (and in its continuations), the continuation inherits the priority and the signal of the task: it fails with the abort reason when the signal is aborted. Otherwise its priority is TaskPriority.UserVisible.

public Task Yield()