[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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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:local="clr-namespace:FancyZonesEditor"
xmlns:ui="http://schemas.modernwpf.com/2019"
Startup="OnStartup">
Startup="OnStartup"
Exit="OnExit">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

View file

@ -57,6 +57,8 @@ namespace FancyZonesEditor
private ThemeManager _themeManager;
private EventWaitHandle _eventHandle;
public static bool DebugMode
{
get
@ -83,8 +85,8 @@ namespace FancyZonesEditor
new Thread(() =>
{
var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, interop.Constants.FZEExitEvent());
if (eventHandle.WaitOne())
_eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, interop.Constants.FZEExitEvent());
if (_eventHandle.WaitOne())
{
Environment.Exit(0);
}
@ -154,6 +156,14 @@ namespace FancyZonesEditor
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)
{
if (e.Key == System.Windows.Input.Key.LeftShift || e.Key == System.Windows.Input.Key.RightShift)