C# - Making a Process.Start wait until the process has start-up

前端 未结 12 2108
迷失自我
迷失自我 2020-11-27 17:12

I need to make sure that a process is running before moving on with a method.

The statement is:

Process.Start(\"popup.exe\");

Can y

12条回答
  •  [愿得一人]
    2020-11-27 18:10

    The answer of 'ChrisG' is correct, but we need to refresh MainWindowTitle every time and it's better to check for empty.... like this:

    var proc = Process.Start("popup.exe");
    while (string.IsNullOrEmpty(proc.MainWindowTitle))
    {
        System.Threading.Thread.Sleep(100);
        proc.Refresh();
    }
    

提交回复
热议问题