本文整理汇总了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();
});
示例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();
}
//.........这里部分代码省略.........