From 15730b15aa36f3e7b43b2963a8c3ca79091ea5af Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 30 Mar 2025 14:59:30 +0800 Subject: [PATCH] Fix Application.Current null exception --- Flow.Launcher/ViewModel/MainViewModel.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 56de70b47..ea1e92b22 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1464,8 +1464,8 @@ namespace Flow.Launcher.ViewModel public void Show() { - // Invoke on UI thread - Application.Current.Dispatcher.Invoke(() => + // When application is exitting, the Application.Current will be null + Application.Current?.Dispatcher.Invoke(() => { // When application is exitting, the Application.Current will be null if (Application.Current?.MainWindow is MainWindow mainWindow) @@ -1539,8 +1539,8 @@ namespace Flow.Launcher.ViewModel break; } - // Invoke on UI thread - Application.Current.Dispatcher.Invoke(() => + // When application is exitting, the Application.Current will be null + Application.Current?.Dispatcher.Invoke(() => { // When application is exitting, the Application.Current will be null if (Application.Current?.MainWindow is MainWindow mainWindow)