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

前端 未结 12 2140
迷失自我
迷失自我 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:08

    I also needed this once, and I did a check on the window title of the process. If it is the one you expect, you can be sure the application is running. The application I was checking needed some time for startup and this method worked fine for me.

    var process = Process.Start("popup.exe");
    while(process.MainWindowTitle != "Title")
    {
        Thread.Sleep(10);
    }
    

提交回复
热议问题