Exemplo n.º 1
0
        public void Test_Repeat_Just()
        {
            int         targetCyclesCompleted = 5;
            IHyperTimer timer = null;

            timer = HyperTimer.StartNew(500, null, (o, e) =>
            {
                Assert.AreEqual(timer.CyclesCompleted, targetCyclesCompleted);
                timer.Dispose();
            })
                    .RepeatJust(targetCyclesCompleted);
        }
Exemplo n.º 2
0
        public void Test_Stop_In()
        {
            int         targetCyclesCompleted = 10;
            int         stopInCycles          = 5;
            IHyperTimer timer = null;

            timer = HyperTimer.StartNew(1000, null, (o, e) =>
            {
                Assert.AreEqual(timer.CyclesCompleted, targetCyclesCompleted - stopInCycles);
                timer.Dispose();
            }).RepeatForever()
                    .RepeatJust(targetCyclesCompleted)
                    .Wait(500)
                    .StopIn(stopInCycles);
        }
Exemplo n.º 3
0
        public void Test_Repeat_More()
        {
            int targetCyclesCompleted = 10;
            int incrementedCycles     = 5;

            IHyperTimer timer = null;

            timer = HyperTimer.StartNew(500, null, (o, e) =>
            {
                Assert.AreEqual(timer.CyclesCompleted, targetCyclesCompleted + incrementedCycles);
                timer.Dispose();
            }).RepeatJust(targetCyclesCompleted)
                    .Wait(1000)
                    .RepeatMore(incrementedCycles);
        }
Exemplo n.º 4
0
        public void Test_Delay()
        {
            int      targetCyclesCompleted  = 10;
            TimeSpan delayTime              = TimeSpan.FromSeconds(5);
            int      intervalInMilliseconds = 1000;

            IHyperTimer timer = null;

            timer = HyperTimer.StartNew(intervalInMilliseconds, null, (o, e) =>
            {
                Assert.IsTrue(TimeSpan.FromMilliseconds(intervalInMilliseconds * targetCyclesCompleted) + delayTime - timer.TotalElapsed < TimeSpan.FromSeconds(1));
                timer.Dispose();
            }).RepeatForever()
                    .RepeatJust(targetCyclesCompleted)
                    .Wait(500)
                    .Delay(TimeSpan.FromSeconds(5));
        }
Exemplo n.º 5
0
 static void timer_Elapsed(IHyperTimer sender, DetailedElapseEventArgs args)
 {
     Console.WriteLine("Cycles Completed:{0}, Cycles Left: {1} TE: {2} Prog: {3}", args.CyclesCompleted, args.CyclesLeft, args.TotalElapsed, args.Elapsed);
     _total += args.Elapsed;
 }
Exemplo n.º 6
0
 static void timer_Elapsed(IHyperTimer sender, DetailedElapseEventArgs args)
 {
     Console.WriteLine("Cycles Completed:{0}, Cycles Left: {1} TE: {2} Prog: {3}", args.CyclesCompleted, args.CyclesLeft, args.TotalElapsed, args.Elapsed);
     _total += args.Elapsed;
 }