diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 56de70b4785..a155d2e43d5 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1464,10 +1464,10 @@ public bool ShouldIgnoreHotkeys() public void Show() { - // Invoke on UI thread - Application.Current.Dispatcher.Invoke(() => + // When application is exiting, the Application.Current will be null + Application.Current?.Dispatcher.Invoke(() => { - // When application is exitting, the Application.Current will be null + // When application is exiting, the Application.Current will be null if (Application.Current?.MainWindow is MainWindow mainWindow) { // 📌 Remove DWM Cloak (Make the window visible normally) @@ -1539,10 +1539,10 @@ public async void Hide() break; } - // Invoke on UI thread - Application.Current.Dispatcher.Invoke(() => + // When application is exiting, the Application.Current will be null + Application.Current?.Dispatcher.Invoke(() => { - // When application is exitting, the Application.Current will be null + // When application is exiting, the Application.Current will be null if (Application.Current?.MainWindow is MainWindow mainWindow) { // Set clock and search icon opacity