mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix environment exit stuck issue
This commit is contained in:
parent
2f53a79a26
commit
b725975b98
2 changed files with 17 additions and 4 deletions
|
|
@ -304,6 +304,14 @@ namespace Flow.Launcher
|
|||
return;
|
||||
}
|
||||
|
||||
// If we call Environment.Exit(0), the application dispose will be called before _mainWindow.Close()
|
||||
// Accessing _mainWindow?.Dispatcher will cause the application stuck
|
||||
// So here we need to check it and just return so that we will not acees _mainWindow?.Dispatcher
|
||||
if (!_mainWindow.CanClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,13 @@ namespace Flow.Launcher
|
|||
{
|
||||
public partial class MainWindow : IDisposable
|
||||
{
|
||||
#region Public Property
|
||||
|
||||
// Window Event: Close Event
|
||||
public bool CanClose { get; set; } = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Fields
|
||||
|
||||
// Dependency Injection
|
||||
|
|
@ -45,8 +52,6 @@ namespace Flow.Launcher
|
|||
private readonly ContextMenu _contextMenu = new();
|
||||
private readonly MainViewModel _viewModel;
|
||||
|
||||
// Window Event: Close Event
|
||||
private bool _canClose = false;
|
||||
// Window Event: Key Event
|
||||
private bool _isArrowKeyPressed = false;
|
||||
|
||||
|
|
@ -279,7 +284,7 @@ namespace Flow.Launcher
|
|||
|
||||
private async void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (!_canClose)
|
||||
if (!CanClose)
|
||||
{
|
||||
_notifyIcon.Visible = false;
|
||||
App.API.SaveAppAllSettings();
|
||||
|
|
@ -287,7 +292,7 @@ namespace Flow.Launcher
|
|||
await PluginManager.DisposePluginsAsync();
|
||||
Notification.Uninstall();
|
||||
// After plugins are all disposed, we can close the main window
|
||||
_canClose = true;
|
||||
CanClose = true;
|
||||
// Use this instead of Close() to avoid InvalidOperationException when calling Close() in OnClosing event
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue