Ejemplo n.º 1
0
 public static async Task MyIteratorMethodInfinite(YieldEnumerator <int, Unit> e)
 {
     for (var n = 0; ; n++)
     {
         await e.YieldReturn(n);
     }
 }
Ejemplo n.º 2
0
        public static async Task MyIteratorBroken2(YieldEnumerator <int, Unit> e)
        {
            await e.YieldReturn(1);

            if (DateTime.Now.Year < 10000)
            {
                throw new IOException("Bad");
            }
        }
Ejemplo n.º 3
0
 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");
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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");
        }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
        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");
            }
        }