diff --git a/src/vs/base/common/event.ts b/src/vs/base/common/event.ts index a8d793e83ea4749ce6d3a74e9d6e2485a016556e..2b68de0c2e37d4831840c6cd740204880a28e79b 100644 --- a/src/vs/base/common/event.ts +++ b/src/vs/base/common/event.ts @@ -257,6 +257,15 @@ export function fromPromise(promise: TPromise): Event { return emitter.event; } +export function toPromise(event: Event): TPromise { + return new TPromise(complete => { + const sub = event(e => { + sub.dispose(); + complete(e); + }); + }); +} + export function delayed(promise: TPromise>): Event { let toCancel: TPromise = null; let listener: IDisposable = null; @@ -511,4 +520,4 @@ export function echo(event: Event, nextTick = false, buffer: T[] = []): Ev }); return emitter.event; -} \ No newline at end of file +} diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 4647e99bcc8c5f167fd73806c3b67259df2ddf41..e0fb2e384aadaa5daf05b3c84f7acc71e640e9ef 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -179,6 +179,10 @@ export class WorkbenchShell { // start cached data manager instantiationService.createInstance(NodeCachedDataManager); + + // Set lifecycle phase to `Runnning` so that other contributions + // can now do something + this.lifecycleService.phase = LifecyclePhase.Running; } }); @@ -235,10 +239,6 @@ export class WorkbenchShell { if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) { this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'.")); } - - // Set lifecycle phase to `Runnning` so that other contributions - // can now do something - this.lifecycleService.phase = LifecyclePhase.Running; } private initServiceCollection(container: HTMLElement): [IInstantiationService, ServiceCollection] { diff --git a/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts b/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts index 820590107e2e003aa878ce55d823b49625f30b23..23945bccb612867152d92113b43408bd57ae2f7f 100644 --- a/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts +++ b/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts @@ -10,6 +10,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import { IExtensionService } from 'vs/platform/extensions/common/extensions'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IMessageService } from 'vs/platform/message/common/message'; +import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { ITimerService } from 'vs/workbench/services/timer/common/timerService'; import { IWindowsService } from 'vs/platform/windows/common/windows'; @@ -20,6 +21,7 @@ import { ReportPerformanceIssueAction } from 'vs/workbench/electron-browser/acti import { TPromise } from 'vs/base/common/winjs.base'; import { join } from 'path'; import { localize } from 'vs/nls'; +import { toPromise, filterEvent } from 'vs/base/common/event'; import { platform, Platform } from 'vs/base/common/platform'; import { readdir, stat } from 'vs/base/node/pfs'; import { release } from 'os'; @@ -149,10 +151,16 @@ class StartupProfiler implements IWorkbenchContribution { @IMessageService private readonly _messageService: IMessageService, @IEnvironmentService private readonly _environmentService: IEnvironmentService, @IInstantiationService private readonly _instantiationService: IInstantiationService, + @ILifecycleService lifecycleService: ILifecycleService, @IExtensionService extensionService: IExtensionService, ) { - - extensionService.onReady().then(() => this._stopProfiling()); + // wait for everything to be ready + TPromise.join([ + extensionService.onReady(), + toPromise(filterEvent(lifecycleService.onDidChangePhase, phase => phase === LifecyclePhase.Running)), + ]).then(() => { + this._stopProfiling(); + }); } getId(): string {