using System;
using System.Diagnostics;
using System.Threading;
namespace process
{
class MainClass
{
static Process proc;
static AutoResetEvent signal;
public static void Main(string[] args)
{
signal = new AutoResetEvent(false);
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.FileName = "ls";
psi.Arguments = "/usr/bin/";
proc = Process.Start(psi);
proc.OutputDataReceived += new DataReceivedEventHandler(get_output);
Console.WriteLine(proc.HasExited.ToString());
proc.BeginOutputReadLine();
//print first line
signal.WaitOne();
//print second line
signal.WaitOne();
}
public static void get_output(object sender,System.Diagnostics.DataReceivedEventArgs e)
{
Console.WriteLine(e.Data);
signal.Set();
}
}
}