One of the FAQs on Coded UI Test is how to make playback wait for certain event? For example, how to wait for the window to show up or how to wait for the progress bar to disappear etc.
The answer is to use appropriate UITestControl.WaitForControlXXX() method from the list below -
Note - This capability was not available in VS 2010 Beta 2 but was added after that.
All these methods have following behaviour -
The above functions are powerful and flexible and should satisfy almost all condition. In case these does not (and I would be interested to know about that) and you need to hard wait\sleep in your code, the recommendation would be use Playback.Wait() API instead of Thread.Sleep() API. The reasons for this are -