Exemplo n.º 1
0
        /// <summary>Waits for availability of the given resource identifier for up to the given time.</summary>
        /// <param name="resourceId">The resource identifier.</param>
        /// <param name="tsWait">The ts wait.</param>
        /// <returns>true if found</returns>
        public bool WaitForAvailableResourceId(string resourceId, TimeSpan tsWait)
        {
            int      timeOut = _controller.GetTimeout();
            DateTime dtWait  = DateTime.Now.AddSeconds(tsWait.TotalSeconds);

            UiSelector uiSelector = new UiSelector().ResourceId(resourceId);
            bool       available  = _controller.DoesScreenContains(uiSelector);

            while (!available && dtWait > DateTime.Now)
            {
                Thread.Sleep(250);
                available = _controller.DoesScreenContains(uiSelector);

                double myTime = dtWait.Subtract(DateTime.Now).TotalSeconds;
                if (myTime % 5 == 0)
                {
                    _controller.PressKey(KeyCode.KEYCODE_WAKEUP);
                }
            }

            _controller.SetTimeout(timeOut);
            return(available);
        }