difference between Process.WaitForInputIdle and App.Sleep : Automation API

difference between Process.WaitForInputIdle and App.Sleep

Class library usage, coding and language questions.

difference between Process.WaitForInputIdle and App.Sleep

Postby nitin » Wed Apr 15, 2009 1:08 pm

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
nitin
 
Posts: 8
Joined: Thu Nov 09, 2006 6:56 am

difference between Process.WaitForInputIdle and App.Sleep

Postby nitin » Thu Apr 16, 2009 9:35 am

Hi All,

Waiting for reply.

Thanks and Regards,
Nitin
nitin
 
Posts: 8
Joined: Thu Nov 09, 2006 6:56 am

Postby Support Team » Thu Apr 16, 2009 10:17 am

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
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

difference between Process.WaitForInputIdle and App.Sleep

Postby nitin » Thu Apr 16, 2009 1:02 pm

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
nitin
 
Posts: 8
Joined: Thu Nov 09, 2006 6:56 am

Postby Support Team » Thu Apr 16, 2009 5:38 pm

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
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests