mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-08 07:44:33 +01:00
lifecycle - emit onWillKill when app.exit
This commit is contained in:
@@ -91,6 +91,13 @@ export interface ILifecycleMainService {
|
||||
*/
|
||||
readonly onBeforeCloseWindow: Event<ICodeWindow>;
|
||||
|
||||
/**
|
||||
* An event that fires in the rare cases where `app.exit` is triggered
|
||||
* and thus we Forcefully shutdown the application. No other lifecycle
|
||||
* event handlers are triggered.
|
||||
*/
|
||||
readonly onWillKill: Event<void>;
|
||||
|
||||
/**
|
||||
* Make a `ICodeWindow` known to the lifecycle main service.
|
||||
*/
|
||||
@@ -117,7 +124,8 @@ export interface ILifecycleMainService {
|
||||
quit(willRestart?: boolean): Promise<boolean /* veto */>;
|
||||
|
||||
/**
|
||||
* Forcefully shutdown the application. No livecycle event handlers are triggered.
|
||||
* Forcefully shutdown the application. The only lifecycle event handler
|
||||
* that is triggered is `onWillKill`.
|
||||
*/
|
||||
kill(code?: number): Promise<void>;
|
||||
|
||||
@@ -169,6 +177,9 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
|
||||
private readonly _onBeforeUnloadWindow = this._register(new Emitter<IWindowUnloadEvent>());
|
||||
readonly onBeforeUnloadWindow = this._onBeforeUnloadWindow.event;
|
||||
|
||||
private readonly _onWillKill = this._register(new Emitter<void>());
|
||||
readonly onWillKill = this._onWillKill.event;
|
||||
|
||||
private _quitRequested = false;
|
||||
get quitRequested(): boolean { return this._quitRequested; }
|
||||
|
||||
@@ -589,6 +600,9 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
|
||||
async kill(code?: number): Promise<void> {
|
||||
this.logService.trace('Lifecycle#kill()');
|
||||
|
||||
// Event
|
||||
this._onWillKill.fire();
|
||||
|
||||
// The kill() method is only used in 2 situations:
|
||||
// - when an instance fails to start at all
|
||||
// - when extension tests run from CLI to report proper exit code
|
||||
|
||||
@@ -57,6 +57,7 @@ suite('StorageMainService', function () {
|
||||
onWillLoadWindow = Event.None;
|
||||
onBeforeCloseWindow = Event.None;
|
||||
onBeforeUnloadWindow = Event.None;
|
||||
onWillKill = Event.None;
|
||||
|
||||
wasRestarted = false;
|
||||
quitRequested = false;
|
||||
|
||||
Reference in New Issue
Block a user