Esempio n. 1
0
        public static void Eventually(TimeSpan timeout, TimeSpan interval, VerifierDelegate verifier)
        {
            DateTime  finalTime = DateTime.Now + timeout;
            Exception err       = null;
            int       tried     = 0;

            while (DateTime.Now < finalTime)
            {
                Thread.Sleep(interval);
                try
                {
                    verifier();
                    err = null;
                    return;
                }
                catch (Exception ex)
                {
                    err = ex;
                    tried++;
                }
            }
            if (null != err)
            {
                string message = $"Still get \"{err.GetType().Name}\" after {timeout} and {tried} trys.";
                throw new EventuallyException(message, err);
            }
        }
Esempio n. 2
0
 public static void Eventually(VerifierDelegate verifier)
 {
     Eventually(DEFAULT_TIMEOUT, DEFAULT_INTERVAL, verifier);
 }