Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     TimingTask tt1 = new TimingTask( new SecendTask(), new TimeSpanTiming(new TimeSpan(0,0,1)) );
     TimingTask tt5 = new TimingTask( new FiveSecendTask(), new TimeSpanTiming(new TimeSpan(0,0,5)) );
     DateTime dt = DateTime.Now.AddSeconds(8);
     TimingTask ttd = new TimingTask( new DayTask(), new DayTiming(new TimeOfDayStructure(dt.Hour, dt.Minute, dt.Second)) );
     TimingTaskCollection ttc = new TimingTaskCollection( tt1, tt5, ttd );
     TimingTaskController Controller = new TimingTaskController( ttc );
     Controller.Start();
     Console.WriteLine("Press [Enter] to exit.");
     Console.ReadLine();
     Controller.Dispose();
 }
Ejemplo n.º 2
0
        public void TestIt()
        {
            var t1 = new MockTask();
            var t2 = new MockTask();
            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 0, 0, 0));
            ITiming ti1 = new DayTiming(new TimeOfDayStructure(1,2,3));
            ITiming ti2 = new DayTiming(new TimeOfDayStructure(1,3,5));
            var ttc = new TimingTaskCollection(new TimingTask(t1, ti1), new TimingTask(t2, ti2));

            var mt = new MockTimer();
            var controller = new TimingTaskController(ttc, mt);
            controller.Start();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 2));
            mt.RaiseElapsed();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 2, 900));
            mt.RaiseElapsed();
            Assert.AreEqual(0, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 3));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 4));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 6));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 4));
            mt.RaiseElapsed();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 5));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 6));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 7));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            Assert.AreEqual(1, t1.Times);
        }
Ejemplo n.º 3
0
		public TimingTaskController(TimingTaskCollection tasks, ITimer it)
		{
			_starting = false;
			this._tasks = tasks;
			_timer = it;
		}
Ejemplo n.º 4
0
		public TimingTaskController(TimingTaskCollection tasks)
			: this(tasks, new ThreadingTimerAdapter(1000)) {}
Ejemplo n.º 5
0
 public TimingTaskController(TimingTaskCollection tasks, ITimer it)
 {
     _starting   = false;
     this._tasks = tasks;
     _timer      = it;
 }
Ejemplo n.º 6
0
 public TimingTaskController(TimingTaskCollection tasks)
     : this(tasks, new ThreadingTimerAdapter(1000))
 {
 }