public void TestPollerDispose() { const int timerIntervalMillis = 10; var timer = new NetMQTimer(TimeSpan.FromMilliseconds(timerIntervalMillis)); var signal = new ManualResetEvent(false); var count = 0; timer.Elapsed += (a, s) => { if (count++ == 5) signal.Set(); }; Poller poller; using (poller = new Poller(timer) { PollTimeout = TestPollTimeoutMillis }) { poller.PollTillCancelledNonBlocking(); Assert.IsTrue(signal.WaitOne(500)); Assert.IsTrue(poller.IsStarted); Assert.Throws<InvalidOperationException>(() => poller.PollTillCancelled()); } Assert.IsFalse(poller.IsStarted); Assert.Throws<ObjectDisposedException>(() => poller.PollTillCancelled()); Assert.Throws<ObjectDisposedException>(() => poller.CancelAndJoin()); Assert.Throws<ObjectDisposedException>(() => poller.AddTimer(timer)); Assert.Throws<ObjectDisposedException>(() => poller.RemoveTimer(timer)); }