[DllImport("kernel32.dll")]
        static extern bool GenerateConsoleCtrlEvent(int dwCtrlEvent, int dwProcessGroupId);

        [DllImport("kernel32.dll")]
        static extern bool SetConsoleCtrlHandler(IntPtr handlerRoutine, bool add);

        [DllImport("kernel32.dll")]
        static extern bool AttachConsole(int dwProcessId);

        public void SendCtrlC()
        {
            AttachConsole();
            SetConsoleCtrlHandler(IntPtr.Zero, true);   //设置自己的ctrl+c处理,防止自己被终止
            GenerateConsoleCtrlEvent(0, 0); // 发送ctrl+c(注意:这是向所有共享该console的进程发送)
            Thread.Sleep(10);
            SetConsoleCtrlHandler(IntPtr.Zero, false);  //重置此参数
        }

留待后查,同时方便他人