Skip to content

Async Library

Rohan Singh edited this page Jan 30, 2015 · 3 revisions

Exports

Async

The Async object contains the following functions.

start

start(action: function)

Starts running a task. action should return an enumerator when called.

start(enumerator: object)

Starts running a task.

run

run(): bool

Runs some tasks. Returns false if all tasks are completed.

runToCompletion

runToCompletion()

Runs tasks until all are completed.

Task

The Task object contains the following functions.

delay

delay(seconds: number): object

Returns a task that will complete after seconds seconds.

delay(seconds: number, cancellationToken: object)

Returns a task that will complete after seconds seconds, or when cancellationToken is canceled.

whenAll

whenAll(...tasks: object): object

Returns a task that will complete after all of tasks have completed.

whenAny

whenAny(...tasks: object): object

Returns a task that will complete when at least one of tasks has completed.

TaskCompletionSource

getTask

setCanceled

setException

setResult

CancellationTokenSource

isCancellationRequested

getToken

cancel

cancelAfter

CancellationToken

isCancellationRequested

register

throwIfCancellationRequested