Tips/tricks/gotchas for using System.Diagnostics.Process and Process.Start [closed]
I've used Process.Start to shell out and call 7zip to archive stuff I've also used it to call ffmpeg to compress video files.
That was a while ago..but I rememeber there was some issue about the pcocess stalling if you don't read off the standardoutput/error. I don't remember everything about it. Does anyone have experience using System.Diagnostics.Process for the purposes of initiating a long running process and waiting for it to finish?
Thanks
If you do not redirect the output it should not be a concern.
If you redirect as I did, using the following to avoid deadlocks. See doumentation for ProcessStartInfo.RedirectStandardOutput at http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx. My longest session was forty minutes scanning my hard drive with ExifTool.
_process.Start()
Dim sXmlOutput As String = _process.StandardOutput.ReadToEnd
Dim sErrOutput As String = _process.StandardError.ReadToEnd
_process.WaitForExit()
精彩评论