private static async CoopTask ExceptionTest1() { var yield = await CoopTask.Capture(); await yield.Yield(); throw new Exception(); }
private static async CoopTask Test2() { var yield = await CoopTask.Capture(); for (var i = 1; i <= 3; i++) { await yield.Yield(); } }
private static async CoopTask Test1() { var yield = await CoopTask.Capture(); await yield.Yield(); await yield.Yield(); await yield.Yield(); }
public static async CoopTask Producer5() { var task = await CoopTask.Capture(); // Capture the underlying 'Task' Console.WriteLine("P 0"); await task.Yield(); // Yield control back to parent await Task.Delay(100).ConfigureAwait(false); // Use any async constructs Console.WriteLine("P 1"); await task.Yield(); // Yield control await Task.Delay(100); Console.WriteLine("P 2"); await task.Break(); // Mark the task as completed Console.WriteLine("P 3"); // Will not be run. }