[FZEditor] stop event waiter (#12529)

This commit is contained in:
Seraphima Zykova
2021-07-28 11:28:01 +03:00
committed by GitHub
parent 7c0cc145eb
commit 88513cf38a
2 changed files with 14 additions and 3 deletions

View File

@@ -3,7 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FancyZonesEditor" xmlns:local="clr-namespace:FancyZonesEditor"
xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:ui="http://schemas.modernwpf.com/2019"
Startup="OnStartup"> Startup="OnStartup"
Exit="OnExit">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>

View File

@@ -57,6 +57,8 @@ namespace FancyZonesEditor
private ThemeManager _themeManager; private ThemeManager _themeManager;
private EventWaitHandle _eventHandle;
public static bool DebugMode public static bool DebugMode
{ {
get get
@@ -83,8 +85,8 @@ namespace FancyZonesEditor
new Thread(() => new Thread(() =>
{ {
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, interop.Constants.FZEExitEvent()); _eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, interop.Constants.FZEExitEvent());
if (eventHandle.WaitOne()) if (_eventHandle.WaitOne())
{ {
Environment.Exit(0); Environment.Exit(0);
} }
@@ -154,6 +156,14 @@ namespace FancyZonesEditor
Overlay.Show(); Overlay.Show();
} }
private void OnExit(object sender, ExitEventArgs e)
{
if (_eventHandle != null)
{
_eventHandle.Set();
}
}
public void App_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) public void App_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{ {
if (e.Key == System.Windows.Input.Key.LeftShift || e.Key == System.Windows.Input.Key.RightShift) if (e.Key == System.Windows.Input.Key.LeftShift || e.Key == System.Windows.Input.Key.RightShift)