WinJS.Utilities.Scheduler.schedule function

Schedules the specified function to execute asynchronously.

Syntax

var winJS.Utilities.Scheduler.IJob = WinJS.Utilities.Scheduler.schedule(work, priority, thisArg, name);

Parameters

  • work
    Type: Function

    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:

Term Description

shouldYield

A boolean value that specifies whether the job should cooperatively yield.

setWork(work)

A field that takes a function that represents the next unit of work to run after this job yields.

setPromise(promise)

A field that takes a Promise. Once this function yields, the scheduler will wait for this Promise to complete before rescheduling the job.

job

An IJob that represents the work item. (You use the schedule method to create the IJob.)

 
  • priority [optional]
    Type: WinJS.Utilities.Scheduler.Priority**

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

  • thisArg [optional]
    Type: Object

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

  • name [optional]
    Type: String

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

Return value

Type: WinJS.Utilities.Scheduler.IJob**

The job instance that represents this work item.

Requirements

Minimum WinJS version

WinJS 2.0

Namespace

WinJS.Utilities.Scheduler