Esempio n. 1
0
        public void Start()
        {
            using (var src = new WakeableTimer())
            {
                src.Interval = TimeSpan.FromMilliseconds(100);
                src.Interval = TimeSpan.FromMilliseconds(100); // ignore
                Assert.That(src.Last.HasValue, Is.False);
                Assert.That(Execute(src, 0, 1), "Timeout");

                var time = src.Last;
                Assert.That(time, Is.Not.EqualTo(DateTime.MinValue));

                src.Reset();
                Assert.That(src.Last, Is.EqualTo(time));
                Assert.That(src.Interval.TotalMilliseconds, Is.EqualTo(100).Within(1.0));
            }
        }
Esempio n. 2
0
        public void Reset()
        {
            using (var timer = new WakeableTimer())
            {
                var ms = 100;

                timer.Interval = TimeSpan.FromMilliseconds(ms);
                timer.Interval = TimeSpan.FromMilliseconds(ms); // ignore
                timer.Start();
                Task.Delay(ms * 2).Wait();
                timer.Stop();

                var last = timer.LastPublished;
                Assert.That(last, Is.Not.EqualTo(DateTime.MinValue));

                timer.Reset();
                Assert.That(timer.LastPublished, Is.EqualTo(last));
                Assert.That(timer.Interval.TotalMilliseconds, Is.EqualTo(ms).Within(1.0));
            }
        }