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

后端 未结 6 1801
臣服心动
臣服心动 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:43

    Perhaps you should implement a solution with the BackgroundWorker. It is easy to implement and does what you want.

    What you have to do is add an instance of a BackgroundWorker in your form, and make the call to the Process running the App.exe from the BackgrondWorker RunWorkerAsync method. Then on you can monitor for a CancelationPending property to stop the process or RunWorkerCompleted event to perform whatever is necessary after the Process has exited.

    There is another SO question, concerning the BackgroundWorker cancelation

提交回复
热议问题