protected void WaitUntil(DoFunc<bool> waitWhile, BuildTimeOutExceptionMessage exceptionMessage) { if (_waitForCompleteTimer == null) throw new WatiNException("_waitForCompleteTimer not initialized"); var timeOut = new TryFuncUntilTimeOut(_waitForCompleteTimer) {ExceptionMessage = exceptionMessage}; timeOut.Try(waitWhile); }
/// <summary> /// Waits until the method returns true or false. /// </summary> /// <param name="func">The function to evaluate.</param> /// <param name="exceptionMessage">A function to build an exception message.</param> /// <returns>The last function result.</returns> /// <exception cref="TimeoutException">Thrown if a timeout occurs.</exception> protected bool WaitUntilNotNull(DoFunc <bool?> func, BuildTimeOutExceptionMessage exceptionMessage) { var result = false; WaitUntil(() => { var currentResult = func(); if (currentResult.HasValue) { result = currentResult.Value; return(true); } return(false); }, exceptionMessage); return(result); }
protected virtual void WaitUntil(DoFunc<bool> waitWhile, BuildTimeOutExceptionMessage exceptionMessage) { if (Timer == null) throw new WatiNException("_waitForCompleteTimer not initialized"); var timeOut = new TryFuncUntilTimeOut(Timer) {ExceptionMessage = exceptionMessage}; timeOut.Try(waitWhile); }
/// <summary> /// Waits until the method returns true or false. /// </summary> /// <param name="func">The function to evaluate.</param> /// <param name="exceptionMessage">A function to build an exception message.</param> /// <returns>The last function result.</returns> /// <exception cref="TimeoutException">Thrown if a timeout occurs.</exception> protected bool WaitUntilNotNull(DoFunc<bool?> func, BuildTimeOutExceptionMessage exceptionMessage) { var result = false; WaitUntil(() => { var currentResult = func(); if (currentResult.HasValue) { result = currentResult.Value; return true; } return false; }, exceptionMessage); return result; }