c# - Console application immediately exits after setting RedirectStandardOutput to true -


i have process needs update console in realtime based on output. not working. console opens , closes, , process runs in background. can not figure out doing wrong. here code:

private static stringbuilder sortoutput = null;  static void main(string[] args) {     process process;     process = new process();     process.startinfo.filename = "c:\\ffmbc\\ffmbc.exe";     //process.startinfo.arguments = "-i new5830df.mxf -an ";     process.startinfo.useshellexecute = false;     process.startinfo.createnowindow = true;     process.startinfo.redirectstandardoutput = true;     sortoutput = new stringbuilder("");      process.outputdatareceived += new datareceivedeventhandler(outputhandler);     process.exited += new eventhandler(myprocess_exited);     process.startinfo.redirectstandardinput = true;     process.start();     process.beginoutputreadline(); }  private static void outputhandler(object sender, datareceivedeventargs outline) {     string line;     line = (outline.data.tostring());     console.writeline(line); }  private static void myprocess_exited(object sender, system.eventargs e) {     console.writeline("proccess finished"); } 

make sure call process.waitforexit() block until process exits.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -