/// Free managed resources protected virtual void Dispose(bool disposing) { if (eventHandler != null) { NativeMethods.SetConsoleCtrlHandler(eventHandler, false); eventHandler = null; } }
/// Constructor public ConsoleCtrl() { // save this to a private var so the GC doesn't collect it... if (Environment.OSVersion.Platform == PlatformID.Win32NT) { try { eventHandler = new NativeMethods.ConsoleControlEventHandler(handler); NativeMethods.SetConsoleCtrlHandler(eventHandler, true); } catch (System.EntryPointNotFoundException) { eventHandler = null; } } }
/// Constructor public ConsoleCtrl() { // save this to a private var so the GC doesn't collect it... if (Environment.OSVersion.Platform == PlatformID.Win32NT) { try { eventHandler = new NativeMethods.ConsoleControlEventHandler(handler); NativeMethods.SetConsoleCtrlHandler(eventHandler, true); } catch (System.EntryPointNotFoundException) { eventHandler = null; } } }
/// Free managed resources protected virtual void Dispose(bool disposing) { if (eventHandler != null) { NativeMethods.SetConsoleCtrlHandler(eventHandler, false); eventHandler = null; } }