@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
58 lines (57 loc) • 2.66 kB
TypeScript
/** Signals to a CancellationToken that it should be canceled. */
export declare class CancellationTokenSource {
private timerHandle;
private disposed;
private canceled;
private readonly cancellationToken;
/**
* Initializes a new instance of the CancellationTokenSource class.
* @param millisecondsDelay The optional time interval in milliseconds to wait before canceling.
*/
constructor(millisecondsDelay?: number);
/** Gets a value indicating whether cancellation has been requested. */
get isCancellationRequested(): boolean;
/** Gets the CancellationToken associated with this CancellationTokenSource. */
get token(): CancellationToken;
/**
* Creates a CancellationTokenSource that will be in the canceled state when any of the source tokens
* in the specified array are in the canceled state.
* @param tokens An array that contains the cancellation token instances to observe.
* @returns A CancellationTokenSource that is linked to the source tokens.
*/
static createLinkedTokenSource(...tokens: CancellationToken[]): CancellationTokenSource;
/** Communicates a request for cancellation. */
cancel(): void;
/**
* Schedules a cancel operation on this CancellationTokenSource after the specified number of milliseconds.
* @param millisecondsDelay The time span to wait before canceling this CancellationTokenSource.
*/
cancelAfter(millisecondsDelay: number): void;
/** Releases all resources used by the current instance of the CancellationTokenSource class. */
dispose(): void;
private cancelTimer;
}
/** Propagates notification that operations should be canceled. */
export declare class CancellationToken {
private readonly source;
private static none;
private readonly parentCancel;
private readonly callbacks;
/**
* Initializes a new instance of the CancellationToken class.
* @param source The underlying CancellationTokenSource.
*/
constructor(source: CancellationTokenSource);
/** Returns an empty CancellationToken value. */
static get NONE(): CancellationToken;
/** Gets a value indicating whether cancellation has been requested for this token. */
get isCancellationRequested(): boolean;
/** Throws an Error if this token has had cancellation requested. */
throwIfCancellationRequested(): void;
/**
* Registers a function that will be called when this CancellationToken is canceled.
* @param callback The function to be executed when the CancellationToken is canceled.
*/
register(callback: () => void): void;
private cancel;
}