I have a snippet of code which basically invokes an application using Process.Start()
method.
ProcessStartInfo psi = new ProcessStartInfo(strAppPath);
psi.WindowStyle = ProcessWindowStyle.Maximized | ProcessWindowStyle.Normal;
//Starts the xyz application process.
Process xyzProcess = Process.Start(psi);
xyzProcess.WaitForInputIdle();
Although the process is started within few seconds, the application can take some amount of time to initialize completely. i.e my application xyz
can take 5 - 10 seconds depending on the machine it is running on (i.e less than 5 secs on a faster pc and >10 secs on slower pc's)
My question : Is there a way to track this ? By polling some property apart from waiting for sometime using Thread.Sleep(ms)
.
I tried using the following approches in vain
Polling
xyzProcess.Responding
property with a smallthread.sleep
Dirty approach of polling
xyzProcess.MainWindowTitle
till it returns some non-null value.xyzProcess.WaitForInputIdle(sleeptime)
;
Please help
Thanks