public void ClearTimeoutTest2() { var manager = new Redial.RedialManager.RedisRedialManager("localhost", null, null); manager.Redis.FlushDb(); manager.Redialer = new TestRedial(); manager.Redis.HashSet(RedisAtomicExecutor.GetSetKey(), Redial.RedialManager.RedisRedialManager.Locker, DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd HH:mm")); RedisAtomicExecutor executor = new RedisAtomicExecutor(manager); Task.Factory.StartNew(() => { executor.Execute("test1", () => { for (int i = 0; i < 5; ++i) { Thread.Sleep(1000); } }); }); Task.Factory.StartNew(() => { executor.Execute("test2", () => { for (int i = 0; i < 5; ++i) { Thread.Sleep(1000); } }); }); Task.Factory.StartNew(() => { executor.Execute("test3", () => { for (int i = 0; i < 5; ++i) { Thread.Sleep(1000); } }); }); DateTime time1 = DateTime.Now; manager.Redial(); DateTime time2 = DateTime.Now; Assert.IsTrue((time2 - time1).Seconds > 4); }
public void RedialTest() { var manager = new Redial.RedialManager.RedisRedialManager("localhost", null, null); manager.Redis.FlushDb(); manager.Redialer = new TestRedial(); RedisAtomicExecutor executor = new RedisAtomicExecutor(manager); Task.Factory.StartNew(() => { executor.Execute("test1", () => { for (int i = 0; i < 5; ++i) { Thread.Sleep(1000); } }); }); Task.Factory.StartNew(() => { executor.Execute("test2", () => { for (int i = 0; i < 5; ++i) { Thread.Sleep(1000); } }); }); Task.Factory.StartNew(() => { executor.Execute("test3", () => { for (int i = 0; i < 5; ++i) { Thread.Sleep(1000); } }); }); DateTime time1 = DateTime.Now; manager.Redial(); DateTime time2 = DateTime.Now; Assert.IsTrue((time2 - time1).Seconds > 4); }