dkilby
asked on
windows forms + check if another program is running
Inside a windows form is there anyway of checking to see if another program is currently running, and if it is wait 5 mins or so and then check again, and keep checking until the other application has been closed, then once closed continuing on with rest of code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How about a blocking approach?
Or an event based approach?
Process[] ps = Process.GetProcessesByName("notepad");
if (ps.Length > 0)
{
ps[0].WaitForExit();
MessageBox.Show("It was closed...");
}
Or an event based approach?
private void Foo()
{
Process[] ps = Process.GetProcessesByName("notepad");
if (ps.Length > 0)
{
ps[0].EnableRaisingEvents = true;
ps[0].Exited += new EventHandler(process_Exited);
}
}
void process_Exited(object sender, EventArgs e)
{
MessageBox.Show("It was closed...");
}
ASKER