Esempio n. 1
0
 public static async Task MyIteratorMethodInfinite(YieldEnumerator <int, Unit> e)
 {
     for (var n = 0; ; n++)
     {
         await e.YieldReturn(n);
     }
 }
Esempio 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");
            }
        }
Esempio 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");
 }
Esempio 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);
        }
Esempio 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");
        }
Esempio 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);
     }
 }
Esempio 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");
            }
        }