My application need to wait until specific process will be started. I am doing it this way
while (Process.GetProcessesByName("someProcess").Length == 0)
{
Thread.Sleep(100);
}
Is there any other way(more elegant) how to accomplish this, with functionality similar to WaitForExit()? Thanks for answers.
Take a look at the ManagementEventWatcher class.
Specifically, the code example at the bottom of the link shows you how to setup a ManagementEventWatcher to be notified when a new process is created.
Code copied from MSDN code example (could stand a little cleanup):
Edit
Simplifed example with
TargetInstance.Name = 'someProcess'filter added.