try solve exception

This commit is contained in:
Kang Yu 2024-04-13 23:12:58 -07:00
parent 60e29af67d
commit 076fc4adc6

View file

@ -10,10 +10,11 @@ namespace PersistentWindows.SystrayShell
public class HotKeyForm : Form public class HotKeyForm : Form
{ {
static HotKeyWindow hkwin = null; static HotKeyWindow hkwin = null;
static Thread messageLoop;
public static void Start(uint hotkey) public static void Start(uint hotkey)
{ {
Thread messageLoop = new Thread(() => messageLoop = new Thread(() =>
{ {
hkwin = new HotKeyWindow(hotkey); hkwin = new HotKeyWindow(hotkey);
Application.Run(new HotKeyForm(hotkey)); Application.Run(new HotKeyForm(hotkey));
@ -58,26 +59,14 @@ namespace PersistentWindows.SystrayShell
base.SetVisibleCore(false); base.SetVisibleCore(false);
} }
/*
#region IDisposable #region IDisposable
public virtual void Dispose(bool disposing)
{
//messageLoop.Abort();
User32.UnregisterHotKey(this.Handle, 0);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~HotKeyForm() ~HotKeyForm()
{ {
Dispose(false); if (messageLoop.IsAlive)
messageLoop.Abort();
User32.UnregisterHotKey(this.Handle, 0);
} }
#endregion #endregion
*/
} }
} }