Thread.Sleep(); is there any better way

Feb 7, 2012 at 6:34 AM

Hi,

Some times when you open a new window it needs time to load and if you referene it while it is loading this will probably will produce a null reference, so what to do so that you can always be sure that you are refering to the elements at the write time and not to wait more than what is needed so not to waste the time

I had used:

subWindow.WaitWhileBusy();

and Thread.Sleep() annd the last one is not practical because each time you run the automated test this waiting time will change and you have to change the code,

so what is the best way to do it?????

 

Feb 7, 2012 at 8:08 AM

Hi

Have a look here Custom Waithandling or implement your own wait handler.

Some possible waiters:

Wait for UIItem is enabled or visible or  text changed(from<->to), we have implement something like this with Timer class.

you can implement something like this also with While and very small Thread.Sleep()

while(!button.Enabled)

{

Thread.Sleep(10);

}

 

Throndorin

Feb 12, 2012 at 7:44 AM

thanks