private bool ConsoleCtrlHandler(ConsoleControlEvent controlType)
        {
            if (controlType == ConsoleControlEvent.CTRL_C_EVENT || controlType == ConsoleControlEvent.CTRL_CLOSE_EVENT ||
                controlType == ConsoleControlEvent.CTRL_SHUTDOWN_EVENT)
            {
                Handler?.Invoke(controlType.ToString());
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        private bool ConsoleCtrlHandler(ConsoleControlEvent controlType)
        {
            if (controlType == ConsoleControlEvent.CTRL_C_EVENT ||
                controlType == ConsoleControlEvent.CTRL_CLOSE_EVENT ||
                controlType == ConsoleControlEvent.CTRL_SHUTDOWN_EVENT)
            {
                Console.WriteLine($"Received event: {controlType}");
                Task.Run(() => _cts.Cancel());
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
 public static extern bool GenerateConsoleCtrlEvent(ConsoleControlEvent ctrlEvent, int processId);
Esempio n. 4
0
 public static extern bool GenerateConsoleCtrlEvent(ConsoleControlEvent ctrlEvent, int processId);