C# controlling a console process
<p>I'm currently working on a program which has to compile a simple c++ program, run it, input something and write the output.
So lets say we have a simple C++ source code. My program woult take the file, compile it, run the resulting exe file, input the values saved in an array, one at a time, and write the resulting output to a label or text area.</p>

<p>Ok, I already managed to write an aplication that would use a default compiler to compile the program, test if there were any errors, warnings, if the exe file was made.</p>

<p>I started the program as a Process, I also managed to redirect the standard output,input.</p>

<p>Now the biggest problem is how to figure out when the process is demanding user input.</p>

<p>Is there any way to control the process, like checking when the program is demanding user input, dynamically writing everything the process spits out,... ?</p>

<p>I already attached a DataReceivedEventHandler to my process, but it's acting a little funny. I think it doesn't trigger until my process outputs a whole line. But I would honestly rather see that every character is written emediately. Espetially cause it can happen that the console program outputs "Press any key to continue..." and this is not a whole line until I don't press any key (input something).</p>

<p>And about checking if my process demands user input:
I can't use patterns in the output to determine if I need to output something. I will have to compile and run many files and the output won't be exactly the same.</p>

<p>So, is there a way to completely take over controll of a process?</p>

<p>Any answer would be apretiated, thx.</p>
