예제 #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);
            }
        }