mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
@ -4,55 +4,40 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
ExtensionContext,
|
||||
StatusBarAlignment,
|
||||
window,
|
||||
StatusBarItem,
|
||||
Selection,
|
||||
workspace,
|
||||
TextEditor,
|
||||
commands,
|
||||
ProgressLocation
|
||||
} from 'vscode';
|
||||
import { ExtensionContext, StatusBarAlignment, window, StatusBarItem, Selection, workspace, TextEditor, commands, ProgressLocation } from 'vscode';
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
context.subscriptions.push(
|
||||
commands.registerCommand('extension.startTask', () => {
|
||||
window.withProgress(
|
||||
{
|
||||
location: ProgressLocation.Notification,
|
||||
title: 'I am long running!',
|
||||
cancellable: true
|
||||
},
|
||||
(progress, token) => {
|
||||
token.onCancellationRequested(() => {
|
||||
console.log('User canceled the long running operation');
|
||||
});
|
||||
context.subscriptions.push(commands.registerCommand('extension.startTask', () => {
|
||||
window.withProgress({
|
||||
location: ProgressLocation.Notification,
|
||||
title: "I am long running!",
|
||||
cancellable: true
|
||||
}, (progress, token) => {
|
||||
token.onCancellationRequested(() => {
|
||||
console.log("User canceled the long running operation")
|
||||
});
|
||||
|
||||
progress.report({ increment: 0 });
|
||||
progress.report({ increment: 0 });
|
||||
|
||||
setTimeout(() => {
|
||||
progress.report({ increment: 10, message: 'I am long running! - still going...' });
|
||||
}, 1000);
|
||||
setTimeout(() => {
|
||||
progress.report({ increment: 10, message: "I am long running! - still going..." });
|
||||
}, 1000);
|
||||
|
||||
setTimeout(() => {
|
||||
progress.report({ increment: 40, message: 'I am long running! - still going even more...' });
|
||||
}, 2000);
|
||||
setTimeout(() => {
|
||||
progress.report({ increment: 40, message: "I am long running! - still going even more..." });
|
||||
}, 2000);
|
||||
|
||||
setTimeout(() => {
|
||||
progress.report({ increment: 50, message: 'I am long running! - almost there...' });
|
||||
}, 3000);
|
||||
setTimeout(() => {
|
||||
progress.report({ increment: 50, message: "I am long running! - almost there..." });
|
||||
}, 3000);
|
||||
|
||||
var p = new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, 5000);
|
||||
});
|
||||
var p = new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
return p;
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
return p;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user