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); }
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); }
public static extern bool GenerateConsoleCtrlEvent(ConsoleControlEvent ctrlEvent, int processId);