本文整理匯總了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();
}
//.........這裏部分代碼省略.........