From efdfcf1f4c9e921c5dddc8a28018e8ea6d094f71 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 4 Feb 2016 19:48:46 +0100 Subject: [PATCH] RunOnceScheduler.isScheduled() --- src/vs/base/common/async.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vs/base/common/async.ts b/src/vs/base/common/async.ts index e7099529bf2..9eadde4da9e 100644 --- a/src/vs/base/common/async.ts +++ b/src/vs/base/common/async.ts @@ -529,7 +529,7 @@ export class RunOnceScheduler { * Cancel current scheduled runner (if any). */ public cancel(): void { - if (this.timeoutToken !== -1) { + if (this.isScheduled()) { platform.clearTimeout(this.timeoutToken); this.timeoutToken = -1; } @@ -557,6 +557,13 @@ export class RunOnceScheduler { this.timeoutToken = platform.setTimeout(this.timeoutHandler, this.timeout); } + /** + * Returns true if scheduled. + */ + public isScheduled(): boolean { + return this.timeoutToken !== -1; + } + private onTimeout() { this.timeoutToken = -1; if (this.runner) {