private static void RegisterConsoleControlHandler() { #if !NETSTANDARD2_0 _consoleCtrlHandler = new ConsoleCtrlMessageHandler(ConsoleCtrlHandler); GC.KeepAlive((object)_consoleCtrlHandler); SetConsoleCtrlHandler(_consoleCtrlHandler, true); #endif }
internal static void RegisterConsoleControlHandler() { if (!ChoConsoleSettings.Me.DisableConsoleCtrlHandler) { _consoleCtrlHandler = new ConsoleCtrlMessageHandler(ConsoleCtrlHandler); GC.KeepAlive(_consoleCtrlHandler); ChoKernel32.SetConsoleCtrlHandler(_consoleCtrlHandler, true); } }
// A private static handler function in the MyApp class. internal static bool ConsoleCtrlHandler(CtrlTypes ctrlType) { ConsoleCtrlMessageHandler consoleCtrlMessageHandler = ChoApplicationHost.ConsoleCtrlMessageReceived; if (consoleCtrlMessageHandler != null) { return(consoleCtrlMessageHandler(ctrlType)); } else { return(OnConsoleCtrlMessage(ctrlType)); } }
internal static extern bool SetConsoleCtrlHandler(ConsoleCtrlMessageHandler consoleCtrlRoutine, bool Add);
private static void RegisterConsoleControlHandler() { _consoleCtrlHandler = new ConsoleCtrlMessageHandler(ConsoleCtrlHandler); GC.KeepAlive((object)_consoleCtrlHandler); SetConsoleCtrlHandler(_consoleCtrlHandler, true); }