当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript base.Promise.cancel方法代码示例

本文整理汇总了TypeScript中vs/base/common/winjs.base.Promise.cancel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript base.Promise.cancel方法的具体用法?TypeScript base.Promise.cancel怎么用?TypeScript base.Promise.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/base/common/winjs.base.Promise的用法示例。


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

示例1: cancel

	public cancel(): void {
		this.cancelTimeout();

		if (this.completionPromise) {
			this.completionPromise.cancel();
			this.completionPromise = null;
		}
	}
开发者ID:inspiredjw,项目名称:VisualStudioCode,代码行数:8,代码来源:async.ts

示例2: test

	test('Throttler - cancel in the middle should not cancel other promises', function (done) {
		let count = 0;
		let factory = () => {
			return TPromise.timeout(0).then(() => {
				return ++count;
			});
		};

		let throttler = new Async.Throttler();
		let p3: Promise;

		Promise.join([
			throttler.queue(factory).then((result) => { assert.equal(result, 1); }, () => { assert(false, 'should not be here, 1'); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 2'); }),
			p3 = throttler.queue(factory).then((result) => { assert(false, 'should not be here, 3'); }, () => { assert(true, 'yes, it was cancelled'); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 4'); })
		]).done(() => done());

		p3.cancel();
	});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:20,代码来源:async.test.ts

示例3: test

	test('Throttler - cancel the first queued promise should not cancel other promises', function(done) {
		var count = 0;
		var factory = () => {
			return Promise.timeout(0).then(() => {
				return ++count;
			});
		};

		var throttler = new Async.Throttler();
		var p2: Promise;

		Promise.join([
			throttler.queue(factory).then((result) => { assert.equal(result, 1); }, () => { assert(false, 'should not be here, 1'); }),
			p2 = throttler.queue(factory).then((result) => { assert(false, 'should not be here, 2'); }, () => { assert(true, 'yes, it was cancelled'); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 3'); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 4'); })
		]).done(() => done());

		p2.cancel();
	});
开发者ID:gaoxiaojun,项目名称:vscode,代码行数:20,代码来源:async.test.ts

示例4: test

	test('Throttler - cancel the first queued promise should not cancel other promises', function () {
		let count = 0;
		let factory = () => {
			return TPromise.timeout(0).then(() => {
				return ++count;
			});
		};

		let throttler = new Async.Throttler();
		let p2: Promise;

		const p = Promise.join([
			throttler.queue(factory).then((result) => { assert.equal(result, 1); }, () => { assert(false, 'should not be here, 1'); }),
			p2 = throttler.queue(factory).then((result) => { assert(false, 'should not be here, 2'); }, () => { assert(true, 'yes, it was cancelled'); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 3'); }),
			throttler.queue(factory).then((result) => { assert.equal(result, 2); }, () => { assert(false, 'should not be here, 4'); })
		]);

		p2.cancel();

		return p;
	});
开发者ID:sameer-coder,项目名称:vscode,代码行数:22,代码来源:async.test.ts

示例5:

		}, () => request.cancel());
开发者ID:asotog,项目名称:vscode,代码行数:1,代码来源:ipc.cp.ts

示例6:

		}, () => {
			this.activePromise.cancel();
		});
开发者ID:inspiredjw,项目名称:VisualStudioCode,代码行数:3,代码来源:async.ts


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