Module Scheduler

Index

Enumerations

Interfaces

Functions

Functions

createOwnerToken(): IOwnerToken

Creates and returns a new IOwnerToken which can be set to the owner property of one or more jobs.

Returns

IOwnerToken

A new IOwnerToken which can be set to the owner property of one or more jobs.

execHigh(callback: () => U): U

Runs the specified callback in a high priority context.

Parameters

  • callback: () => U

    The callback to run in a high priority callback.

Returns

U

The return value of the callback.

requestDrain(priority?: Priority, name?: string): Promise

Runs jobs in the scheduler without timeslicing until all jobs at the specified priority and higher have executed.

Parameters

  • priority?: Priority optional

    The priority to which the scheduler should drain. The default is -15.

  • name?: string optional

    An optional description of the drain request for diagnostics.

Returns

Promise

A Promise which completes when the drain has finished. Canceling this Promise cancels the drain request. This Promise will never enter an error state.

retrieveState(): string

Returns a string representation of the scheduler's state for diagnostic purposes. The jobs and drain requests are displayed in the order in which they are currently expected to be processed. The current job and drain request are marked by an asterisk.

Returns

string

A string representation of the scheduler's state for diagnostic purposes. The jobs and drain requests are displayed in the order in which they are currently expected to be processed. The current job and drain request are marked by an asterisk.

schedule(work: (jobInfo: WinJS.Utilities.Scheduler.IJobInfo) => any, priority?: Priority, thisArg?: any, name?: string): IJob

Schedules the specified function to execute asynchronously.

Parameters

  • work: (jobInfo: WinJS.Utilities.Scheduler.IJobInfo) => any

    A function that represents the work item to be scheduled. When called the work item will receive as its first argument an object which allows the work item to ask the scheduler if it should yield cooperatively and if so allows the work item to either provide a function to be run as a continuation or a WinJS.Promise which will when complete provide a function to run as a continuation. Provide these fields for the object: shouldYield, setWork(work), setPromise(promise), job.

  • priority?: Priority optional

    The priority of the work item. If you don't specify a priority, it defaults to WinJS.Utilities.Scheduler.Priority.normal.

  • thisArg?: any optional

    A "this" instance to be bound to the work item. The default value is null.

  • name?: string optional

    A description of the work item for diagnostics. The default value is an empty string.

Returns

IJob

The job instance that represents this work item.

schedulePromiseAboveNormal(promiseValue?: U, jobName?: string): Promise

Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.aboveNormal priority.

Parameters

  • promiseValue?: U optional

    The value returned by the completed Promise.

  • jobName?: string optional

    A string that describes the job for diagnostic purposes.

Returns

Promise

A Promise that completes within a job of aboveNormal priority.

schedulePromiseBelowNormal(promiseValue?: U, jobName?: string): Promise

Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.belowNormal priority.

Parameters

  • promiseValue?: U optional

    The value returned by the completed Promise.

  • jobName?: string optional

    A string that describes the job for diagnostic purposes.

Returns

Promise

A Promise that completes within a job of belowNormal priority.

schedulePromiseHigh(promiseValue?: U, jobName?: string): Promise

Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.high priority.

Parameters

  • promiseValue?: U optional

    The value returned by the completed Promise.

  • jobName?: string optional

    A string that describes the job for diagnostic purposes.

Returns

Promise

A Promise that completes within a job of high priority.

schedulePromiseIdle(promiseValue?: U, jobName?: string): Promise

Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.Idle priority.

Parameters

  • promiseValue?: U optional

    The value returned by the completed Promise.

  • jobName?: string optional

    A string that describes the job for diagnostic purposes.

Returns

Promise

A Promise that completes within a job of idle priority.

schedulePromiseNormal(promiseValue?: U, jobName?: string): Promise

Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.normal priority.

Parameters

  • promiseValue?: U optional

    The value returned by the completed Promise.

  • jobName?: string optional

    A string that describes the job for diagnostic purposes.

Returns

Promise

A Promise that completes within a job of normal priority.