From c46149a375dd82519f071c2df7f88ca11dbc818d Mon Sep 17 00:00:00 2001 From: Syrone Wong Date: Fri, 30 Sep 2016 15:00:33 +0800 Subject: [PATCH] Fix hotkey dispose Signed-off-by: Syrone Wong --- shadowsocks-csharp/Util/Hotkeys.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shadowsocks-csharp/Util/Hotkeys.cs b/shadowsocks-csharp/Util/Hotkeys.cs index f5d8e3d..5b148a0 100644 --- a/shadowsocks-csharp/Util/Hotkeys.cs +++ b/shadowsocks-csharp/Util/Hotkeys.cs @@ -22,7 +22,11 @@ namespace Shadowsocks.Util _hotKeyManager.KeyPressed += HotKeyManagerPressed; } - public static void Destroy() => _hotKeyManager.Dispose(); + public static void Destroy() + { + _hotKeyManager.KeyPressed -= HotKeyManagerPressed; + _hotKeyManager.Dispose(); + } private static void HotKeyManagerPressed(object sender, KeyPressedEventArgs e) { @@ -79,7 +83,8 @@ namespace Shadowsocks.Util } } - public static HotKey Str2HotKey( string s ) { + public static HotKey Str2HotKey(string s) + { try { if (s.IsNullOrEmpty()) return null;