c# - how can i check if the process got output? -


is there way indicate if process standard calculator got output or not,
need because have line :

sr = p1.standardoutput;   

and need :

s = sr.readline();   

only if there's output p1 in calculator example there's no output program stuck after readline.
all.

the code :

while (i < asprocesses.length - 1)             {                 if ((i + 1) == asprocesses.length - 1 && soutredirect != "")                     break;                 p1.startinfo.redirectstandardoutput = true;                 p1.startinfo.filename = asprocesses[i];                 p1.startinfo.useshellexecute = false;                 if(i==0)                     p1.start();                 sr = p1.standardoutput;                 process p2 = new process();                 p2.startinfo.redirectstandardinput = true;                 p2.startinfo.filename = asprocesses[i + 1];                 p2.startinfo.useshellexecute = false;                 p2.start();                 sw = p2.standardinput;                 while (!sr.endofstream && s != null)                 {                     s = sr.readline();                     if (s != null)                     {                         sw.writeline(s);                     }                 }                 if (sw != null)                     sw.close();                 if (sr != null)                     sr.close();                 i++;             } 

void foo() {     system.diagnostics.process p = new system.diagnostics.process();     p.startinfo.filename = "c:\\windows\\system32\\ping.exe";     p.startinfo.redirectstandardoutput = true;     p.startinfo.useshellexecute = false;     p.enableraisingevents = true;     p.outputdatareceived += new system.diagnostics.datareceivedeventhandler(p_outputdatareceived);     p.start();     p.beginoutputreadline(); }             void p_outputdatareceived(object sender, system.diagnostics.datareceivedeventargs e) {     string s = e.data;             // process s } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -