Hi Andrey_F,

> Of course, if you set a breakpoint in RunTest method. The res may have value.

It has correct value in 99.999% cases when the Thread.Sleep calls are removed. And the sample in MSDN is doing this in exactly the same way. So I assumed that it's the officially recommended way how this task should be done.



> One variable is only assigned in one thread. For example, outputDataReceived only assigned in OutputDataReceived thread. It will not cause conflicts with shared resources.

This variable is assigned in a background thread that invokes callbacks, and is read from the main thread. This code is not thread safe and incorrect due to possible compiler/runtime optimizations and partial read/write problems.



> Whether standard and error provide output or not,both OutputDataReceived and ErrorDataReceived methods will be raised.

Even if the lunar phase is favorable and this code doesn't fail, it will handle only a single portion of the incoming process output. And the output can come in multiple portions, exact number unknown.

This can be checked very easily by replacing output args to " /C echo TEST & echo TEST & echo TEST"

