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

前端 未结 12 2113
迷失自我
迷失自我 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 17:48

    I agree with Tom. In addition, to check the processes while performing Thread.Sleep, check the running processes. Something like:

    bool found = 0;
    while (!found)
    {
        foreach (Process clsProcess in Process.GetProcesses())
            if (clsProcess.Name == Name)
                found = true;
    
        Thread.CurrentThread.Sleep(1000);
    }
    

提交回复
热议问题