2014-02-08 30 views
0

當我使用Process類來啓動的Python象下面WaitForExit掛起(在一個線程)C#工藝:開始蟒

ProcessStartInfo info = new ProcessStartInfo(); 
info.FileName = "python.exe"; 
info.Arguments = "test.py"; 
Process p = new Process(); 
p.StartInfo = info; 
p.RedirectStandardOutput = true; 
p.RedirectStandardError = true; 
... 
p.Start(); 
p.WaitForExit(); 

時的Python有錯誤結束(蟒進程不再在Windows任務管理器示出了),WaitForExit仍然掛起。但是,如果我使用IronPython,它可以正常工作。誰能告訴我爲什麼?

+0

請參見[這裏](http://stackoverflow.com/editing-help#links)學習如何鏈接到「單獨的線程」你說話的。它可能會爲想要幫助你的人提供有用的信息。 – jbaums

回答

0

已解決。重定向和ErrorDataReceived/OutputDataReceived事件實現會導致此問題,請改用Redirects和StreamReader。