tags:

views:

31

answers:

1

Hello

I know I can read console buffer using ReadConsoleOutput function. Is there any way to be notified when console app is outputing text ? Currently I need to set timer and scan the console buffer all the time.

Ty.

+1  A: 

Not 100% sure I totally understand what you're trying to do - would this help?

Process process = new Process();

process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += 
    new DataReceivedEventHandler(HandleConsoleOutput);

process.Start( );

and then handle all output being written to the console output by that process using this handler:

void HandleConsoleOutput(object sender, DataReceivedEventArgs e)
{
  // Std output arrives here
}

Marc

marc_s
Notice the WINAPI tag :) Thanx for the sample anyway, it made me remember I have somewhere similar api code...
majkinetor