CUDA_Manager.Form1.SendControlC C# (CSharp) Метод

SendControlC() публичный Метод

public SendControlC ( Process proc ) : void
proc System.Diagnostics.Process
Результат void
        void SendControlC(Process proc)
        {
            try
            {
                try
                {
                    p.CancelOutputRead();
                    p.CancelErrorRead();
                }
                catch { }

                //This does not require the console window to be visible.
                Process[] localByName = Process.GetProcessesByName("cudaminer");
                if (AttachConsole((uint)proc.Id))
                {
                    SetConsoleCtrlHandler(null, true);
                    GenerateConsoleCtrlEvent(CtrlTypes.CTRL_C_EVENT, 0);
                    int timer = 0;
                    while (localByName.Count() == Process.GetProcessesByName("cudaminer").Count() && localByName.Count() > 0)
                    {
                        timer++;
                        //Twiddle our thumbs for a second.
                        if (timer > 30)
                        {
                            GenerateConsoleCtrlEvent(CtrlTypes.CTRL_C_EVENT, 0);
                        }
                        Thread.Sleep(20);
                    }
                    FreeConsole();

                    SetConsoleCtrlHandler(null, false);
                }
                proc.Kill();
            }
            catch
            {
                //there wasn't a process to close anyway.
            }
        }