Visual C# GUI stops responding when process.WaitForExit(); is used

后端 未结 6 1796
臣服心动
臣服心动 2020-12-12 01:14

I am creating a GUI application using Visual C# 2005 (net framework 2). I use the following code to start a process:

Process process = new Process();
process         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 01:39

    In order to receive a callback on Exited event, the EnableRaisingEvents must be set to true.

    Process correctionProcess = Process.Start(startInfo);
    correctionProcess.EnableRaisingEvents = true;
    correctionProcess.Exited += new EventHandler(ProcessExited); 
    

    Using exited worked well for me and gave me great flexibility to either run sequentially, partially concurrently, or all at once - without locking the UI.

提交回复
热议问题