While googlin im having only Information how to get All Processes ,store into Process[] ,but what i need is :
Process proc = new Process();
proc.startInfo.FileName = "notepad.exe";
proc.Start();
Below i created a Process Object ,now i need to know if this Process is Closed ,exactly this one because if User Closes and if i try from Code proc.Exit(); it throws an Exception .
So far im doing like :
Process procs = new Process();
Process[] proc = Process.GetProcesses();
foreach (Process p in proc)
{
if (p.Id = procs.Id)
{
//Do Something
break;
}
}
Just use
HasExitedon yourProcessobject:Or, if you want to be notified as soon as the process has been closed, use the
Exitedevent: