[C#][Waiting for Process]

05/15/2013 16:17 szymek111#1
Hi guys ! Can anyone give me code that wait for process ? I need this
05/15/2013 16:27 #SoNiice#2
Timer -> check processlist
05/15/2013 17:09 dready#3
Or incase you want todo something when the process starts, spawn him yourself
05/17/2013 07:38 redskull010101#4
using something suchas this could work for ya
Code:
using System.Diagnostics;
            var pName = "League of Legends";
            bool isRunning = false;

            Console.Write("Waiting for " + pName + " to launch...");
            while (!isRunning)
            {
                foreach (Process clsProcess in Process.GetProcesses())
                {
                    if (clsProcess.ProcessName == "Chrome")
                    {
                        isRunning = true;
                    }
                }
                Thread.Sleep(1000);
            }
05/17/2013 11:32 #SoNiice#5
That's a better performance at waiting for processes.
05/17/2013 12:14 Shawak#6
Shorter version:

Code:
using System.Diagnostics;

            var pName = "League of Legends";
            Console.Write("Waiting for " + pName + " to launch...");
            while (Process.GetProcessesByName(pName).Length=0)
            {
                Thread.Sleep(100);
            }