c# - Process.Start leaves streams empty -


i have code run console command/utility, monitor live output using 'debug.writeline' , write final output log file when needed.

edit: not work praatcon.exe analysis command line utility. can downloaded from here . invoke praatcon.exe without argument, should write on 'stdout' usage. code wont catch it.

the issue is, works utilities , can see debug output log in file. utilities, see empty commands, though when run commands through cmd window, see output. capturing both streams output , error.

can me ?

full code can found here

here how trying it

initialization of processstartinfo

        var info = new processstartinfo(command, parameters)         {             workingdirectory = workingdirectory,             useshellexecute = false,             redirectstandardoutput = true,             redirectstandarderror = true,             createnowindow = true         }; 

running process , initializing string builders output , error streams.

        var process = process.start(info);          var output = new stringbuilder();         var error = new stringbuilder(); 

starting tasks reading streams

        var errortask = process.standarderror.readlineasync();          var linetask = process.standardoutput.readlineasync(); 

here while loop monitor progress , write output debug output window when there available.

            while (process.hasexited == false)             {                 if (linetask.iscompleted)                 {                     output.appendline(linetask.result);                      debug.writeline(linetask.result);                      linetask = process.standardoutput.readlineasync();                 }                  if (errortask.iscompleted)                 {                     error.appendline(errortask.result);                      debug.writeline(errortask.result);                      errortask = process.standarderror.readlineasync();                 }                  errortask.wait(timespan.frommilliseconds(100.0));                 linetask.wait(timespan.frommilliseconds(100.0));             } 

after this, reading streams further see if there left in there.

i empty strings in output , error 1 command. thing correct 'exitcode'.

please tell me if there doing wrong way.

as discussed on irc, there possibility program you're calling may have been writing stream other standard out or standard error. there streams numbers 3-9 on windows.

this not case process calling. using win32 call 'writeconsole', seems access console directly.

it possible move output stderr preloading dll (dll injection) hackish, source of program available, it's perhaps better 'fix' or submit patch authors.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -