示例#1
0
 public void Cancel()
 {
     int executionCount = 0;
     Action action = () => executionCount++;
     var timer = new TimerAction(StubFiber.StartNew(), action, TimeSpan.FromMilliseconds(2));
     Thread.Sleep(100);
     Assert.AreEqual(1, executionCount);
     timer.Dispose();
     Thread.Sleep(150);
     Assert.AreEqual(1, executionCount);
 }
示例#2
0
        public void Cancel()
        {
            int    executionCount = 0;
            Action action         = () => executionCount++;
            var    timer          = new TimerAction(StubFiber.StartNew(), action, TimeSpan.FromMilliseconds(2));

            Thread.Sleep(100);
            Assert.AreEqual(1, executionCount);
            timer.Dispose();
            Thread.Sleep(150);
            Assert.AreEqual(1, executionCount);
        }
示例#3
0
        public void Cancel()
        {
            var    executionCount = 0;
            Action action         = () => executionCount++;
            var    timer          = new TimerAction(action, 1, 2);

            timer.ExecuteOnFiberThread();
            Assert.AreEqual(1, executionCount);
            timer.Dispose();
            timer.ExecuteOnFiberThread();

            Assert.AreEqual(1, executionCount);
        }
示例#4
0
        public void CallbackFromIntervalTimerWithCancel()
        {
            var mocks    = new MockRepository();
            var action   = mocks.CreateMock <Action>();
            var timer    = new TimerAction(action, 2, 3);
            var registry = mocks.CreateMock <ISchedulerRegistry>();

            registry.Remove(timer);

            mocks.ReplayAll();

            timer.Dispose();
            timer.ExecuteOnTimerThread(registry);
        }
示例#5
0
        public void Cancel()
        {
            int executionCount = 0;

            void Action()
            {
                executionCount++;
            }

            TimerAction timer = new TimerAction(new StubFiber(), Action, TimeSpan.FromMilliseconds(2));

            Thread.Sleep(100);
            Assert.AreEqual(1, executionCount);
            timer.Dispose();
            Thread.Sleep(150);
            Assert.AreEqual(1, executionCount);
        }
示例#6
0
 public void CallbackFromIntervalTimerWithCancel()
 {
     int executionCount = 0;
     Action action = () => executionCount++;
     using (IFiber stubFiber = StubFiber.StartNew())
     {
         var timer = new TimerAction(stubFiber,
             action,
             TimeSpan.FromMilliseconds(2),
             TimeSpan.FromMilliseconds(150));
         Thread.Sleep(100);
         Assert.AreEqual(1, executionCount);
         timer.Dispose();
         Thread.Sleep(150);
         Assert.AreEqual(1, executionCount);
     }
 }
示例#7
0
        public void CallbackFromIntervalTimerWithCancel()
        {
            int    executionCount = 0;
            Action action         = () => executionCount++;

            using (IFiber stubFiber = StubFiber.StartNew())
            {
                var timer = new TimerAction(stubFiber,
                                            action,
                                            TimeSpan.FromMilliseconds(2),
                                            TimeSpan.FromMilliseconds(150));
                Thread.Sleep(100);
                Assert.AreEqual(1, executionCount);
                timer.Dispose();
                Thread.Sleep(150);
                Assert.AreEqual(1, executionCount);
            }
        }
示例#8
0
        public void CallbackFromIntervalTimerWithCancel()
        {
            int executionCount = 0;

            void Action()
            {
                executionCount++;
            }

            using (StubFiber stubFiber = new StubFiber())
            {
                TimerAction timer = new TimerAction(stubFiber,
                                                    Action,
                                                    TimeSpan.FromMilliseconds(2),
                                                    TimeSpan.FromMilliseconds(150));
                Thread.Sleep(100);
                Assert.AreEqual(1, executionCount);
                timer.Dispose();
                Thread.Sleep(150);
                Assert.AreEqual(1, executionCount);
            }
        }