예제 #1
0
        // starts a background thread that calls retry with exponentially increasing waiting in between
        public Thread StartRetryThread()
        {
            Thread t = new Thread(o =>
            {
                // int startingWaitingTime = (int) o;
                SimpleRetry.ExponentialDo(() =>
                {
                    Retry();
                }, TimeSpan.FromSeconds(0.1));
            });

            t.Start();
            return(t);
        }
        public void RunTest()
        {
            var retry = new SimpleRetry(
                100,
                (ex) =>
            {
            });

            retry.Start();
            var success = 0;

            retry.Retry(
                new TimeSpan(0, 0, 0, 0, 5),
                () => { Interlocked.Exchange(ref success, 1); });
            Thread.Sleep(20);
            Assert.AreEqual(1, Volatile.Read(ref success));
        }