public void TestExecuteOthers([Values(1, 2, 3, 4)] int mode) { OcDispatcher dispatcher = new OcDispatcher(2); ManualResetEventSlim mres = new ManualResetEventSlim(); bool done = false; object context = new object(); dispatcher.InvokeAsync(() => { mres.Wait(); Assert.AreEqual(done, false); switch (mode) { case 1: dispatcher.ExecuteOtherInvocations(); break; case 2: dispatcher.ExecuteOtherInvocations(1); break; case 3: dispatcher.ExecuteOtherInvocations(TimeSpan.FromSeconds(1)); break; case 4: dispatcher.ExecuteOtherInvocations((count, invocation) => invocation.Context == context); break; } Assert.AreEqual(done, true); }); dispatcher.InvokeAsync(() => { done = true; }, 0, context); mres.Set(); dispatcher.Pass(); Exception exception = null; try { switch (mode) { case 1: dispatcher.ExecuteOtherInvocations(); break; case 2: dispatcher.ExecuteOtherInvocations(1); break; case 3: dispatcher.ExecuteOtherInvocations(TimeSpan.FromSeconds(1)); break; case 4: dispatcher.ExecuteOtherInvocations((count, invocation) => invocation.Context == context); break; } } catch (Exception e) { exception = e; } Assert.IsNotNull(exception); dispatcher.Dispose(); }