Wait for process to finish and then display message (C#)

前端 未结 3 1653
梦毁少年i
梦毁少年i 2020-12-11 19:57

I would like to be able to watch a process until it is terminated, and once non existent display a message, how could this be achieved?

3条回答
  •  抹茶落季
    2020-12-11 20:34

    I think this is what you want to do:

    System.Diagnostics.Process process=new System.Diagnostics.Process();
    process.StartInfo.FileName = "process.exe";
    process.Start();
    process.WaitForExit();
    //process ended
    MessageBox.Show("Process terminated");
    

提交回复
热议问题