From b71e7226e5bbc1ff852e4a71064c72afae3f7558 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 21 Mar 2025 21:17:31 +0800 Subject: [PATCH] Improve & Fix --- Flow.Launcher/App.xaml.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 8f7c8aec9..63dcdf353 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -243,23 +243,23 @@ namespace Flow.Launcher private void RegisterExitEvents() { - AppDomain.CurrentDomain.ProcessExit += (s, e) => + AppDomain.CurrentDomain.ProcessExit += async (s, e) => { Log.Info("|App.RegisterExitEvents|Process Exit"); - _ = DisposeAsync(); + await DisposeAsync(); }; - Current.Exit += (s, e) => + Current.Exit += async (s, e) => { NativeThreadCTS.Cancel(); Log.Info("|App.RegisterExitEvents|Application Exit"); - _ = DisposeAsync(); + await DisposeAsync(); }; - Current.SessionEnding += (s, e) => + Current.SessionEnding += async (s, e) => { Log.Info("|App.RegisterExitEvents|Session Ending"); - _ = DisposeAsync(); + await DisposeAsync(); }; } @@ -303,6 +303,8 @@ namespace Flow.Launcher _disposed = true; } + await Task.Delay(10000); + await Stopwatch.NormalAsync("|App.Dispose|Dispose cost", async () => { Log.Info("|App.Dispose|Begin Flow Launcher dispose ----------------------------------------------------"); @@ -313,7 +315,7 @@ namespace Flow.Launcher await PluginManager.DisposePluginsAsync(); // Dispose needs to be called on the main Windows thread, since some resources owned by the thread need to be disposed. - await _mainWindow?.Dispatcher.InvokeAsync(DisposeAsync); + await _mainWindow?.Dispatcher.InvokeAsync(_mainWindow.Dispose); _mainVM?.Dispose(); }