• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript async.RunOnceScheduler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vs/base/common/async.RunOnceScheduler的典型用法代码示例。如果您正苦于以下问题:TypeScript RunOnceScheduler类的具体用法?TypeScript RunOnceScheduler怎么用?TypeScript RunOnceScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RunOnceScheduler类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: colorize

	public static colorize(modeService:IModeService, text:string, mimeType:string, options:IColorizerOptions): TPromise<string> {
		options = options || {};
		if (typeof options.tabSize === 'undefined') {
			options.tabSize = 4;
		}

		let lines = text.split('\n');
		let c: (v:string)=>void;
		let e: (err:any)=>void;
		let p: (v:string)=>void;
		let isCanceled = false;
		let mode: IMode;

		let result = new TPromise<string>((_c, _e, _p) => {
			c = _c;
			e = _e;
			p = _p;
		}, () => {
			isCanceled = true;
		});

		let colorize = new RunOnceScheduler(() => {
			if (isCanceled) {
				return;
			}
			let r = actualColorize(lines, mode, options.tabSize);
			if (r.retokenize.length > 0) {
				// There are retokenization requests
				r.retokenize.forEach((p) => p.then(scheduleColorize));
				p(r.result);
			} else {
				// There are no (more) retokenization requests
				c(r.result);
			}
		}, 0);
		let scheduleColorize = () => colorize.schedule();

		modeService.getOrCreateMode(mimeType).then((_mode) => {
			if (!_mode) {
				e('Mode not found: "' + mimeType + '".');
				return;
			}
			if (!_mode.tokenizationSupport) {
				// wait 500ms for mode to load, then give up
				TPromise.any([this._tokenizationSupportChangedPromise(_mode), TPromise.timeout(500)]).then(_ => {
					if (!_mode.tokenizationSupport) {
						e('Mode found ("' + _mode.getId() + '"), but does not support tokenization.');
						return;
					}
					mode = _mode;
					scheduleColorize();
				});
				return;
			}
			mode = _mode;
			scheduleColorize();
		});

		return result;
	}
开发者ID:GYGit,项目名称:vscode,代码行数:60,代码来源:colorizer.ts


示例2: onCursorPositionChanged

	private onCursorPositionChanged(): void {
		if (this.triggerAutoSuggestPromise) {
			this.triggerAutoSuggestPromise.cancel();
			this.triggerAutoSuggestPromise = null;
		}
		this.cancelDialog();

		if (!this.updateScheduler) {
			this.updateScheduler = new RunOnceScheduler(() => {

				const pos = this.editor.getPosition();
				let marker = this.lastMarker;
				if (marker && Range.containsPosition(marker, pos)) {
					// still on the same marker
					if (this.lightBulpPosition) {
						this.setDecoration(pos);
					}
					return;
				}

				if (!this.editor.isFocused()) {
					// remove lightbulb when editor lost focus
					this.setDecoration(null);
					return;
				}

				this.lastMarker = marker = this.findMarker(pos, false);
				if (!marker) {
					// remove lightbulp
					this.setDecoration(null);
					return;
				}

				const $tRequest = timer.start(timer.Topic.EDITOR, 'quickfix/lighbulp');
				const computeFixesPromise = this.computeFixes(marker);
				computeFixesPromise.done((fixes) => {
					this.setDecoration(!arrays.isFalsyOrEmpty(fixes) ? pos : null);
					this.triggerAutoSuggest(marker);
					$tRequest.stop();
				}, (error) => {
					onUnexpectedError(error);
					this.setDecoration(null);
					$tRequest.stop();
				});
			}, 250);
			this.toLocalDispose.push(this.updateScheduler);
		}
		this.updateScheduler.schedule();
	}
开发者ID:eklavyamirani,项目名称:vscode,代码行数:49,代码来源:quickFixModel.ts


示例3:

	show(delay?: number): void {
		this.showDelayedScheduler.cancel();

		if (typeof delay === 'number') {
			this.showDelayedScheduler.schedule(delay);
		} else {
			show(this.element);
		}
	}
开发者ID:developers23,项目名称:vscode,代码行数:9,代码来源:progressbar.ts


示例4:

		this._toDispose.push(this._editor.addListener2(editorCommon.EventType.ModelContentChanged, (e:editorCommon.IModelContentChangedEvent) => {
			if (this._ignoreModelContentChanged) {
				return;
			}
			if (e.changeType === editorCommon.EventType.ModelContentChangedFlush) {
				// a model.setValue() was called
				this._decorations.reset();
			}
			this._decorations.setStartPosition(this._editor.getPosition());
			this._updateDecorationsScheduler.schedule();
		}));
开发者ID:Elflyy,项目名称:vscode,代码行数:11,代码来源:findModel.ts


示例5: cancel

	public cancel(): void {
		this._loadingMessageScheduler.cancel();
		if (this._state === ComputeHoverOperationState.FIRST_WAIT) {
			this._firstWaitScheduler.cancel();
		}
		if (this._state === ComputeHoverOperationState.SECOND_WAIT) {
			this._secondWaitScheduler.cancel();
			if (this._asyncComputationPromise) {
				this._asyncComputationPromise.cancel();
				this._asyncComputationPromise = null;
			}
		}
		if (this._state === ComputeHoverOperationState.WAITING_FOR_ASYNC_COMPUTATION) {
			if (this._asyncComputationPromise) {
				this._asyncComputationPromise.cancel();
				this._asyncComputationPromise = null;
			}
		}
		this._state = ComputeHoverOperationState.IDLE;
	}
开发者ID:,项目名称:,代码行数:20,代码来源:


示例6: start

	public start(mode: HoverStartMode): void {
		if (mode === HoverStartMode.Delayed) {
			if (this._state === ComputeHoverOperationState.IDLE) {
				this._state = ComputeHoverOperationState.FIRST_WAIT;
				this._firstWaitScheduler.schedule(this._firstWaitTime());
				this._loadingMessageScheduler.schedule(this._loadingMessageTime());
			}
		} else {
			switch (this._state) {
				case ComputeHoverOperationState.IDLE:
					this._triggerAsyncComputation();
					this._secondWaitScheduler.cancel();
					this._triggerSyncComputation();
					break;
				case ComputeHoverOperationState.SECOND_WAIT:
					this._secondWaitScheduler.cancel();
					this._triggerSyncComputation();
					break;
			}
		}
	}
开发者ID:,项目名称:,代码行数:21,代码来源:


示例7: _triggerAsyncComputation

	private _triggerAsyncComputation(): void {
		this._state = ComputeHoverOperationState.SECOND_WAIT;
		this._secondWaitScheduler.schedule(this._secondWaitTime());

		if (this._computer.computeAsync) {
			this._asyncComputationPromiseDone = false;
			this._asyncComputationPromise = createCancelablePromise(token => this._computer.computeAsync!(token));
			this._asyncComputationPromise.then((asyncResult: Result) => {
				this._asyncComputationPromiseDone = true;
				this._withAsyncResult(asyncResult);
			}, (e) => this._onError(e));

		} else {
			this._asyncComputationPromiseDone = true;
		}
	}
开发者ID:,项目名称:,代码行数:16,代码来源:


示例8:

		var scheduleColorize = () => colorize.schedule();
开发者ID:13572293130,项目名称:vscode,代码行数:1,代码来源:colorizer.ts



注:本文中的vs/base/common/async.RunOnceScheduler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript async.Sequencer类代码示例发布时间:2022-05-25
下一篇:
TypeScript async.ResourceQueue类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap