public static async Task MyIteratorMethodInfinite(YieldEnumerator <int, Unit> e) { for (var n = 0; ; n++) { await e.YieldReturn(n); } }
public static async Task MyIteratorBroken2(YieldEnumerator <int, Unit> e) { await e.YieldReturn(1); if (DateTime.Now.Year < 10000) { throw new IOException("Bad"); } }
public static async Task MyIteratorMethod3(YieldEnumerator <int, string> e) { Console.WriteLine("A"); Console.WriteLine(await e.YieldReturn(1)); Console.WriteLine("B"); Console.WriteLine(await e.YieldReturn(2)); Console.WriteLine("C"); Console.WriteLine(await e.YieldReturn(3)); Console.WriteLine("D"); }
public static async Task MyIteratorBroken1(YieldEnumerator <int, Unit> e) { // always happens, but compiler doesn't know that if (DateTime.Now.Year < 10000) { throw new IOException("Bad"); } await e.YieldReturn(1); }
public static async Task MyIteratorMethod1(YieldEnumerator <int, Unit> e) { Console.WriteLine("A"); await e.YieldReturn(1); Console.WriteLine("B"); await e.YieldReturn(2); Console.WriteLine("C"); await e.YieldReturn(3); Console.WriteLine("D"); }
public static async Task MyIteratorMethod4(YieldEnumerator <int, string> e) { try { Console.WriteLine("A"); Console.WriteLine(await e.YieldReturn(1)); Console.WriteLine("B"); Console.WriteLine(await e.YieldReturn(2)); Console.WriteLine("C"); Console.WriteLine(await e.YieldReturn(3)); Console.WriteLine("D"); } catch (IOException x) { Console.WriteLine(x.Message); } }
public static async Task MyIteratorMethod2(YieldEnumerator <int, Unit> e) { try { Console.WriteLine("A"); await e.YieldReturn(1); Console.WriteLine("B"); await e.YieldReturn(2); Console.WriteLine("C"); await e.YieldReturn(3); Console.WriteLine("D"); } finally { Console.WriteLine("Running finally"); } }