UNPKG

@freemework/common

Version:

Common library of the Freemework Project.

27 lines 875 B
import { FCancellationTokenSourceManual } from "./f_cancellation_token_source_manual.js"; export class FCancellationTokenSourceTimeout extends FCancellationTokenSourceManual { _timeoutHandler; constructor(timeout) { super(); this._timeoutHandler = setTimeout(() => { if (this._timeoutHandler !== undefined) { delete this._timeoutHandler; } super.cancel(); }, timeout); } cancel() { this.stopTimer(); super.cancel(); } /** * After call this method, the instance behaves is as `FManualCancellationTokenSource` */ stopTimer() { if (this._timeoutHandler !== undefined) { clearTimeout(this._timeoutHandler); delete this._timeoutHandler; } } } //# sourceMappingURL=f_cancellation_token_source_timeout.js.map