public void TestCancellation() { _jobCount = 0; AsyncProcessor processor = new AsyncProcessor(); using ( processor ) { TimedJob job = new TimedJob(); processor.QueueJobAt(DateTime.Now.AddSeconds(4), job); processor.QueueJobAt(DateTime.Now.AddSeconds(4.01), job); processor.CancelTimedJobs(job); processor.QueueEndOfWork(); processor.WaitUntilFinished(); if (_jobCount != -2) { throw new Exception("TestCancellation() failed. _jobCount = " + _jobCount); } } }