// protected static void AbortMethod(object data) { ProcStatus status = (ProcStatus)data; if (status == null || status.proc == null) { return; } FreeConsole(); AttachConsole((uint)status.proc.Id); SetConsoleCtrlHandler(null, true); GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); status.exit_event.WaitOne(2000); // Die wicked-witch if (status.running) { try { status.proc.Kill(); } catch { } } FreeConsole(); SetConsoleCtrlHandler(null, false); }
// ctor public AsyncProcess(string Command, string Options = "", CallbackEventHandler OnOutput = null, CallbackEventHandler OnError = null, int Timeout = Timeout.Infinite) { status = new ProcStatus(); cmd = Command; opt = Options; if (OnOutput != null) { OutputCallback += OnOutput; } if (OnError != null) { ErrorCallback += OnError; } timeout = Timeout; }