public void AddTwoHandlers_UseHighDivider_CallbacksFired() { int callback1Count = 0; int callback2Count = 0; int divider = 200; using (var timer = new CallbackTimer(TimerMode.Periodic)) { timer.AddCallbackHandler((sender, e) => { callback1Count++; }, 1, null); timer.AddCallbackHandler((sender, e) => { callback2Count++; }, divider, null); timer.StartTimer(); Thread.Sleep(500); Assert.AreNotEqual(0, callback1Count); Assert.AreNotEqual(0, callback2Count); Assert.AreEqual(callback1Count / divider, callback2Count); } }
public void AddTwoHandlers_UseHighDivider_CallbacksFired() { int callback1Count = 0; int callback2Count = 0; int divider = 200; using (var timer = new CallbackTimer(TimerMode.Periodic)) { #if NET4 timer.AddCallbackHandler((sender, e) => { callback1Count++; }, 1, null); timer.AddCallbackHandler((sender, e) => { callback2Count++; }, divider, null); #else timer.AddCallbackHandler((sender, e) => { callback1Count++; }, 1); timer.AddCallbackHandler((sender, e) => { callback2Count++; }, divider); #endif timer.StartTimer(); Thread.Sleep(500); callback1Count.Should().BeGreaterThan(0); callback2Count.Should().BeGreaterThan(0); callback2Count.Should().Be(callback1Count / divider); } }