private static void Unhook(KeyBoardHook hook) { if (hook != null) { hook.UnHook(); GC.Collect(); } }
void Unhook() { if (KeyBoarHook != null) { KeyBoarHook.UnHook(); KeyBoarHook.OnKeyDownEvent -= KeyBoarHook_OnKeyDownEvent; GC.Collect();//增加GC防止窗体关闭后,钩子未被卸载. } }