Process WaitForExit LongProcess

  • Thread starter Thread starter mazda_88
  • Start date Start date
M

mazda_88

I have a fairly simple subroutine written in .net that will run an
executable. It creates a process, starts it and then waitforexit
(long time period). It then checks to make sure that the process has
exited. If not the process is killed. The program works fine if the
process completes within 30 seconds. If the process takes longer, it
looks like the process is no longer given any cpu time.

When the executable is robocopy, it works fine as long as the copy
completes within 30 seconds. However if the copy takes longer, it is
like the process is hung.

I also ran the robocopy from the dos prompt for a large directory and
it works fine.

If I run the same robocopy from my subroutine for a large directory it
hangs after 30 seconds.


Is there a parameter that needs to be set to allow for long processes.

Thanks,
 
Never mind. I found the problem. The output and error data was being
piped to a buffer. This buffer was not being read until the process
was completed. If this buffer gets filled before the process
completes, a deadlock occurs. I added the statement,
StandardOutput.ReadToEnd and the same one for StandardError before
calling waitforexit, which took care of the problem.
This feature is documented in MSDN.
 
Back
Top