Page 1 of 1

difference between Process.WaitForInputIdle and App.Sleep

Posted: Wed Apr 15, 2009 12:08 pm
by nitin
Hi All,

I am testing Visual Studio Addin, so my test open visual studio process and do some tests now problem is at the time of closing its take too much time
so, i have to wait till the process is properly exist

Added code like
==============================================
if (vsProcess.HasExited) return;
Application.Sleep(1000);
vsProcess.WaitForInputIdle(waitTimeMaxMsecsShutdown);
vsProcess.CloseMainWindow();
vsProcess.WaitForExit(waitTimeMaxMsecsShutdown);
Application.Sleep(2000);
int count = 0;
while (!vsProcess.HasExited && count < 5 )
{
this.SaveSolution();
Application.Sleep(200);
}
if (!vsProcess.HasExited)
{
vsProcess.Kill();
throw new Exception("Can not close Visual Studio -> Killed it");
}
==============================================

is it optimize way to check process exit or else kill it after few time.
Any good solution from Ranorex.

samething for opening visual studio as it take too much time so cant predict how much handle it.



Thanks and Regards,
Nitin

difference between Process.WaitForInputIdle and App.Sleep

Posted: Thu Apr 16, 2009 8:35 am
by nitin
Hi All,

Waiting for reply.

Thanks and Regards,
Nitin

Posted: Thu Apr 16, 2009 9:17 am
by Support Team
Hi Nitin,

To check whether your application is closed you can use the find method to search for it (e.g. by its title). If your app is closed the find method's return value will be null then.

The latest Ranorex 2.0 version gives you a better support for searching GUI elements with long loading times.

Kind regards,
Gabor
Ranorex Support Team

difference between Process.WaitForInputIdle and App.Sleep

Posted: Thu Apr 16, 2009 12:02 pm
by nitin
Hi Gabor,

Thanks for reply,

Could you please tell me, what is meaning of below these API.

vsProcess is visual studio process
=======================
bool done = false;
Element statusBar = StatusBar;
while (!done && count < 20)
{
count++;
vsProcess.WaitForInputIdle(waitTimeMaxMsecs);
Application.Sleep(100);
if (statusBar != null && statusBar.Value.StartsWith(statusBarContent))
done = true;
}
=======================
Here i am trying to wait still visual studio is properly open in "Ready" Status within waitTimeMaxMsecs=10000 same loop 20 times.

Is these two APIs (WaitForInputIdle and Sleep) together required or only one can handle this. mean only one using WaitForInputIdle or Sleep function.

Thanks and Regards,
Nitin

Posted: Thu Apr 16, 2009 4:38 pm
by Support Team
The Process.WaitForInputIdle method is a .NET Framework method, please consult the .NET Framework documentation:
http://msdn.microsoft.com/en-us/library/kcdbkyt4.aspx

The Ranorex.Application.Sleep method suspends the currently running thread for the specified number of milliseconds.

I can't answer your question whether you need both since this heavily depends on your application. In general, I would rather try to search for a control/element inside the application in a loop until you find the control/element. In Ranorex 2.0 this is done by default if you search for an element.

Regards,
Alex
Ranorex Support Team