Skip to content

Commit b71e722

Browse files
committed
Improve & Fix
1 parent 783cef6 commit b71e722

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Flow.Launcher/App.xaml.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,23 @@ private void AutoUpdates()
243243

244244
private void RegisterExitEvents()
245245
{
246-
AppDomain.CurrentDomain.ProcessExit += (s, e) =>
246+
AppDomain.CurrentDomain.ProcessExit += async (s, e) =>
247247
{
248248
Log.Info("|App.RegisterExitEvents|Process Exit");
249-
_ = DisposeAsync();
249+
await DisposeAsync();
250250
};
251251

252-
Current.Exit += (s, e) =>
252+
Current.Exit += async (s, e) =>
253253
{
254254
NativeThreadCTS.Cancel();
255255
Log.Info("|App.RegisterExitEvents|Application Exit");
256-
_ = DisposeAsync();
256+
await DisposeAsync();
257257
};
258258

259-
Current.SessionEnding += (s, e) =>
259+
Current.SessionEnding += async (s, e) =>
260260
{
261261
Log.Info("|App.RegisterExitEvents|Session Ending");
262-
_ = DisposeAsync();
262+
await DisposeAsync();
263263
};
264264
}
265265

@@ -303,6 +303,8 @@ protected virtual async ValueTask DisposeAsync(bool disposing)
303303
_disposed = true;
304304
}
305305

306+
await Task.Delay(10000);
307+
306308
await Stopwatch.NormalAsync("|App.Dispose|Dispose cost", async () =>
307309
{
308310
Log.Info("|App.Dispose|Begin Flow Launcher dispose ----------------------------------------------------");
@@ -313,7 +315,7 @@ await Stopwatch.NormalAsync("|App.Dispose|Dispose cost", async () =>
313315
await PluginManager.DisposePluginsAsync();
314316

315317
// Dispose needs to be called on the main Windows thread, since some resources owned by the thread need to be disposed.
316-
await _mainWindow?.Dispatcher.InvokeAsync(DisposeAsync);
318+
await _mainWindow?.Dispatcher.InvokeAsync(_mainWindow.Dispose);
317319
_mainVM?.Dispose();
318320
}
319321

0 commit comments

Comments
 (0)