My application launches a console application. Captures output and sends the console application input. This all works great. When I am done with the console application I can exit currentProcess without issue. My problem occurs when my main application crashes or exits irregularly. The ConsoleExeFile remains in the task manager and is now using up a full core of CPU usage. I then have to kill the ConsoleExeFile in task manager.
// Set the options.
ProcessStartInfo processStartInfo = new ProcessStartInfo(ConsoleExeFile, "");
// Set the options.
processStartInfo.UseShellExecute = false;
processStartInfo.ErrorDialog = false;
processStartInfo.CreateNoWindow = true;
// Specify redirection.
processStartInfo.RedirectStandardError = false;
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
// Create the process.
currentProcess = new Process();
currentProcess.EnableRaisingEvents = true;
currentProcess.StartInfo = processStartInfo;
currentProcess.Exited += new EventHandler(currentProcess_Exited);
currentProcess.OutputDataReceived += currentProcess_OutputDataReceived;
// start the process.
currentProcess.Start();