Process.Start is blocking/hanging randomly on some clients

非 Y 不嫁゛ 提交于 2019-12-05 05:27:31

I understand this thread is kind of old, but if anyone is interested, this is caused by a shell extension(in this case, the antivirus software). Basically, when you start with UseShellExecute=true(default), the antivirus software interferes with Processor.Start and makes it hang(seems to be random). Interestingly, the process starts just fine, it's the caller thread that hangs.

We had the very same issue with Symantec Virus protection being enabled in one of our client's servers. We fixed it by setting up exceptions on the antivirus software. Alternatively, you can disable UseShellExecute.

I had a problem a while ago where shelling out to an external process could lead to a race condition if something else was reading the program output at the wrong time. Could this be what you're seeing?

More information on the MSDN article on StandardOutput.

edit: Memory slowly returns. I was using process.ReadToEnd() after process.WaitforExit(). The output buffer is quite small so was effectively filling up then stopping, waiting for something (me, i.e the process caller) to read it. Which of course it couldn't do because my code was still waiting for the process to finish.

Putting process.ReadToEnd() before WaitForExit() fixed it for me, couterintuitive though that sounds. But if you're not spitting verbose output to the console then it's probably something else entirely...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!