>The documentation on the StandardError property (
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standarderror.aspx) says that ReadToEnd will not complete until the process writes to its error stream or closes it. This can create a deadlock if it writes to its output stream first. See the paragraphs just prior to the examples section. It also details how to use the asynchronous methods like BeginErrorReadLine to avoid the deadlock.
>
>You will probably want to use the WaitForExit method (
http://msdn.microsoft.com/en-us/library/ty0d8k56.aspx) to have the process finish before you continue instead of waiting the arbitrary 7 seconds. The WaitForExit call will need to be after reading the StandardError and StandardOutput streams or using their asynchronous equivalents.
Thanks, I read both of them.
I see they also mention to use Close() to free the allocating memory. I had assumed that this was not needed once we get out of the caller class as the scope of the object would have disappear.
I will add the following lines at the end:
oProcess.WaitForExit()
oProcess.Close()
The first one should be as you said. The second one is based on what I read in the 2nd document. Do you think that one is really necessary?
I haven't tested anything yet, as to know about removing the 7 seconds timeout and see if the problem we had earlier will not happen with this new setup.