Last active
January 6, 2016 01:42
-
-
Save rbuckton/b69be537e41feec7fea7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A source for cancellation | |
*/ | |
export declare class CancellationTokenSource { | |
/** | |
* @param links Other `CancellationToken` instances that will cancel this source if the tokens are canceled. | |
*/ | |
constructor(links?: CancellationToken[]); | |
/** | |
* Gets the `CancellationToken` for this source. | |
*/ | |
token: CancellationToken; | |
/** | |
* Signals the source is cancelled. | |
* @param reason An optional reason for the cancellation. | |
*/ | |
cancel(reason?: any): void; | |
/** | |
* Closes the CancellationSource, preventing any future cancellation signal. | |
*/ | |
close(): void; | |
} | |
/** | |
* A token used to recieve a cancellation signal. | |
*/ | |
export declare class CancellationToken { | |
/** | |
* Gets an empty cancellation token that will never be canceled. | |
*/ | |
static none: CancellationToken; | |
/** | |
* Gets a value indicating whether the token can be canceled. | |
*/ | |
canBeCanceled: boolean; | |
/** | |
* Gets a value indicating whether the token has received a cancellation signal. | |
*/ | |
cancellationRequested: boolean; | |
/** | |
* Gets the reason for cancellation, if one was supplied. | |
*/ | |
reason: any; | |
/** | |
* Throws an `Error` if the token has received a cancellation signal. | |
*/ | |
throwIfCancellationRequested(reason?: any): void; | |
/** | |
* Requests a callback when the token receives a cancellation signal to perform additional cleanup. | |
* @param callback The callback to execute | |
* @returns A `CancellationTokenRegistration` that that can be used to cancel the cleanup request. | |
*/ | |
register(callback: (reason: any) => void): CancellationTokenRegistration; | |
} | |
/** | |
* An object used to unregister a callback delegate registered to a `CancellationToken` | |
*/ | |
export interface CancellationTokenRegistration { | |
/** | |
* Unregisters the callback | |
*/ | |
unregister(): void; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment