public void TestEvent() { dispatcher.Append(new WebTimeJob() { TestContext = TestContext, Repeat = -1 }); dispatcher.DispatchFinished += Dispatcher_DispatchFinished; new Thread(() => { Thread.Sleep(20 * 1000); dispatcher.Halt(); }).Start(); while (!flag) { Thread.Sleep(100); } }