public async Task ActionTest() { var dispatcher = new FizzActionDispatcher(); bool fired1 = false; bool fired2 = false; var checkpoint1 = new TaskCompletionSource <object>(); var checkpoint2 = new TaskCompletionSource <object>(); dispatcher.Post(() => { Assert.IsFalse(fired1); Assert.IsFalse(fired2); fired1 = true; checkpoint1.SetResult(null); }); dispatcher.Post(() => { Assert.IsTrue(fired1); Assert.IsFalse(fired2); fired2 = true; checkpoint2.SetResult(null); }); dispatcher.Process(); await checkpoint1.Task; await checkpoint2.Task; }
public async Task ReentrantActionTest() { FizzActionDispatcher dispatcher = new FizzActionDispatcher(); var checkpoint1 = new TaskCompletionSource <object>(); var checkpoint2 = new TaskCompletionSource <object>(); dispatcher.Post(() => { dispatcher.Post(() => checkpoint2.SetResult(null)); checkpoint1.SetResult(null); }); dispatcher.Process(); await checkpoint1.Task; dispatcher.Process(); await checkpoint2.Task; }