예제 #1
0
        static async Task MainAsync(string[] args)
        {
            Coffee cup = Coffee.PourCoffee();

            Console.WriteLine("coffee is ready");

            var eggsTask  = Egg.FryEggsAsync(2);
            var baconTask = Bacon.FryBaconAsync(3);
            var toastTask = Toast.MakeToast_withButterAndJam_Async(2);

            //Egg eggs = await Egg.FryEggs(2);
            var eggs = await eggsTask;

            Console.WriteLine("eggs are ready");

            //Bacon bacon = await Bacon.FryBacon(3);
            var bacon = await baconTask;

            Console.WriteLine("bacon is ready");

            //Toast toast = Toast.ToastBread(2);
            var toast = await toastTask;

            Console.WriteLine("toast is ready");

            Juice oj = Juice.PourOJ();

            Console.WriteLine("oj is ready");
            Console.WriteLine("Breakfast is ready!");
        }
예제 #2
0
        static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();

#if SYNC
            sw.Start();

            Coffee cup = Coffee.PourCoffee();
            Console.WriteLine("coffee is ready");

            Egg eggs = Egg.FryEggs(2);
            Console.WriteLine("eggs are ready");

            Bacon bacon = Bacon.FryBacon(3);
            Console.WriteLine("bacon is ready");

            Toast toast = Toast.ToastBread(2);
            Toast.ApplyButter(toast);
            Toast.ApplyJam(toast);
            Console.WriteLine("toast is ready");

            Juice oj = Juice.PourOJ();
            Console.WriteLine("oj is ready");
            Console.WriteLine("Breakfast is ready!");

            sw.Stop();
            Console.WriteLine("END TIME = " + sw.ElapsedMilliseconds.ToString() + " msec");
#endif

#if ASYNC
            sw.Start();

            MainAsync(args).GetAwaiter().GetResult();

            sw.Stop();
            Console.WriteLine("END TIME = " + sw.ElapsedMilliseconds.ToString() + " msec");
#endif

            Console.ReadKey();
        }