News for hackers. Stuff that matters.
Re:Cmd - A saner way to running external programs from C# by duncans on Saturday December 08, 2012 @02:18PM (#4892416)
Nice idea. A few problems spring to mind:

* Doing the following will hang if the stdout buffer fills up:

    var output = process.StandardOutput.ReadToEnd();
    process.WaitForExit();
Take a look at Kudu (Azure's Git publishing platform) for the way they do it: https://github.com/projectkudu/kudu/blob/master/Kudu.Core/In...

* You need to expose a way to capture `StandardError`.

Re:Cmd - A saner way to running external programs from C# by timrobinson on Saturday December 08, 2012 @06:04PM (#4893032)
It won't hang as long as you're redirecting only standard output. If you want to read both StandardOutput and StandardError, you need to do it from separate threads: either with explicit BeginInvoke/EndInvoke calls as in Kudu, or more simply, by listening on the OutputDataReceived/ErrorDataReceived events then calling BeginOutputReadLine/BeginErrorReadLine.

(The reason for this is that the two streams are redirected to separate pipes, each of which has its own fixed-size buffer. If you forget to read from one pipe while you read from the other, its buffer fills up, and the writer - the program being executed - blocks. With standard error redirection turned off, the program writes directly to the console, which is safe.)

Re:Cmd - A saner way to running external programs from C# by manojlds on Sunday December 09, 2012 @12:25AM (#4893918)
Yes, I have so for been working on getting the Base API right. Will be adding background process, stderr redirect etc. Thanks for the input.