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


TypeScript CancellationTokenSource.dispose方法代码示例

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


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

示例1: test

	test('#7013 - input without options', function () {
		const source = new CancellationTokenSource();
		let p = window.showInputBox(undefined, source.token);
		assert.ok(typeof p === 'object');
		source.dispose();
	});
开发者ID:sandy081,项目名称:vscode,代码行数:6,代码来源:window.test.ts

示例2: show

    async show(
        placeHolder: string,
        options: ReferencesQuickPickOptions = {}
    ): Promise<ReferencesQuickPickItem | CommandQuickPickItem | undefined> {
        const cancellation = new CancellationTokenSource();

        let scope;
        if (options.goBack) {
            scope = await Container.keyboard.beginScope({ left: options.goBack });
        }

        let autoPick;
        try {
            let items = this.getItems(options, cancellation.token);
            if (options.autoPick) {
                items = items.then(itms => {
                    if (itms.length <= 1) {
                        autoPick = itms[0];
                        cancellation.cancel();
                    }
                    return itms;
                });
            }

            let pick;
            if (options.allowEnteringRefs) {
                placeHolder += `${GlyphChars.Space.repeat(3)}(select or enter a reference)`;

                const quickpick = window.createQuickPick<ReferencesQuickPickItem | CommandQuickPickItem>();
                quickpick.busy = true;
                quickpick.enabled = false;
                quickpick.placeholder = placeHolder;
                quickpick.ignoreFocusOut = getQuickPickIgnoreFocusOut();
                quickpick.show();

                quickpick.items = await items;
                quickpick.busy = false;
                quickpick.enabled = true;

                pick = await new Promise<ReferencesQuickPickItem | CommandQuickPickItem | undefined>(resolve => {
                    cancellation.token.onCancellationRequested(() => quickpick.hide());

                    quickpick.onDidHide(() => resolve(undefined));
                    quickpick.onDidAccept(async () => {
                        if (quickpick.selectedItems.length === 0) {
                            quickpick.busy = true;
                            quickpick.enabled = false;

                            const ref = quickpick.value;
                            if (
                                this.repoPath === undefined ||
                                (await Container.git.validateReference(this.repoPath, ref))
                            ) {
                                resolve(new RefQuickPickItem(ref));
                            }
                            else {
                                quickpick.title = 'You must enter a valid reference';
                                quickpick.busy = false;
                                quickpick.enabled = true;
                                return;
                            }
                        }
                        else {
                            resolve(quickpick.selectedItems[0]);
                        }

                        quickpick.hide();
                    });
                });

                quickpick.dispose();
            }
            else {
                pick = await window.showQuickPick(
                    items,
                    {
                        placeHolder: placeHolder,
                        ignoreFocusOut: getQuickPickIgnoreFocusOut()
                    },
                    cancellation.token
                );
            }

            if (pick === undefined && autoPick !== undefined) {
                pick = autoPick;
            }

            if (pick === undefined) {
                cancellation.cancel();
            }

            return pick;
        }
        finally {
            if (scope !== undefined) {
                await scope.dispose();
            }

            cancellation.dispose();
        }
//.........这里部分代码省略.........
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:101,代码来源:referencesQuickPick.ts


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