Last active
May 26, 2025 14:41
-
-
Save oofnivek/2dda49617417c1f962b5c2f4709bf200 to your computer and use it in GitHub Desktop.
Synchronous application for comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace LearnAsync; | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var start = DateTime.Now; | |
| Coffee coffee = PourCoffee(); | |
| Console.WriteLine("coffee is ready"); | |
| Egg egg = FryEgg(2); | |
| Console.WriteLine("eggs are ready"); | |
| Bacon bacon = FryBacon(3); | |
| Console.WriteLine("bacon is ready"); | |
| Toast toast = ToastBread(2); | |
| ApplyButter(toast); | |
| ApplyJam(toast); | |
| Console.WriteLine("toast is ready"); | |
| Juice juice = PourJuice(); | |
| Console.WriteLine("breakfast is ready"); | |
| var end = DateTime.Now; | |
| Console.WriteLine("total time= {0} pretend minutes", (end-start).Seconds); | |
| } | |
| static Juice PourJuice() | |
| { | |
| Console.WriteLine("pouring juice"); | |
| return new Juice(); | |
| } | |
| static Coffee PourCoffee() | |
| { | |
| Console.WriteLine("pouring coffee"); | |
| return new Coffee(); | |
| } | |
| static void ApplyJam(Toast toast) | |
| { | |
| Console.WriteLine("putting jam on the toast"); | |
| } | |
| static void ApplyButter(Toast toast) | |
| { | |
| Console.WriteLine("putting butter on the toast"); | |
| } | |
| static Toast ToastBread(int quantity) | |
| { | |
| for (int i = 0; i < quantity; i++) | |
| { | |
| Console.WriteLine("putting a slice of bread in the toaster"); | |
| } | |
| Console.WriteLine("start toasting"); | |
| for (int i = 0; i < 3; i++) | |
| { | |
| Task.Delay(1000).Wait(); | |
| Console.WriteLine($"toasting {i}"); | |
| } | |
| Console.WriteLine("remove toast from toaster"); | |
| return new Toast(); | |
| } | |
| static Bacon FryBacon(int quantity) | |
| { | |
| Console.WriteLine($"putting {quantity} slices of bacon in the pan"); | |
| Console.WriteLine("cooking first side of bacon"); | |
| for (int i = 0; i < 3; i++) | |
| { | |
| Task.Delay(1000).Wait(); | |
| Console.WriteLine($"frying bacon {i}"); | |
| } | |
| for (int i = 0; i < quantity; i++) | |
| { | |
| Console.WriteLine("flipping slice of bacon"); | |
| } | |
| Console.WriteLine("cooking the other side of bacon"); | |
| for (int i = 0; i < 3; i++) | |
| { | |
| Task.Delay(1000).Wait(); | |
| Console.WriteLine($"frying bacon {i}"); | |
| } | |
| Console.WriteLine("putting bacon on plate"); | |
| return new Bacon(); | |
| } | |
| static Egg FryEgg(int quantity) | |
| { | |
| Console.WriteLine($"cracking {quantity} eggs"); | |
| Console.WriteLine("cooking the eggs"); | |
| for (int i = 0; i < 6; i++) | |
| { | |
| Task.Delay(1000).Wait(); | |
| Console.WriteLine($"frying eggs {i}"); | |
| } | |
| Console.WriteLine("put eggs on plate"); | |
| return new Egg(); | |
| } | |
| } | |
| class Juice() { } | |
| class Coffee() { } | |
| class Toast() { } | |
| class Bacon() { } | |
| class Egg() { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment