diff --git a/docs/csharp/programming-guide/concepts/async/index.md b/docs/csharp/programming-guide/concepts/async/index.md index bde2cdc82db10..d38d24a659644 100644 --- a/docs/csharp/programming-guide/concepts/async/index.md +++ b/docs/csharp/programming-guide/concepts/async/index.md @@ -25,15 +25,12 @@ For a parallel algorithm, you'd need multiple cooks (or threads). One would make Now, consider those same instructions written as C# statements: -:::code language="csharp" source="snippets/index/AsyncBreakfast-starter/Program.cs" highlight="8-27"::: +:::code language="csharp" source="snippets/index/AsyncBreakfast-starter/Program.cs" highlight="8-34"::: :::image type="content" source="media/synchronous-breakfast.png" alt-text="synchronous breakfast"::: The synchronously prepared breakfast took roughly 30 minutes because the total is the sum of each task. -> [!NOTE] -> The `Coffee`, `Egg`, `Bacon`, `Toast`, and `Juice` classes are empty. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. - Computers don't interpret those instructions the same way people do. The computer will block on each statement until the work is complete before moving on to the next statement. That creates an unsatisfying breakfast. The later tasks wouldn't be started until the earlier tasks had been completed. It would take much longer to create the breakfast, and some items would have gotten cold before being served. If you want the computer to execute the above instructions asynchronously, you must write asynchronous code. diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs index b8c1813fabf15..5ef08ea14136c 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Program.cs @@ -6,6 +6,13 @@ namespace AsyncBreakfast class Program { // + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + static async Task Main(string[] args) { Coffee cup = PourCoffee(); diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs index 55686db83691e..92cec48ad47aa 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Program.cs @@ -6,11 +6,18 @@ namespace AsyncBreakfast class Program { // + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + static async Task Main(string[] args) { Coffee cup = PourCoffee(); Console.WriteLine("coffee is ready"); - + var eggsTask = FryEggsAsync(2); var baconTask = FryBaconAsync(3); var toastTask = MakeToastWithButterAndJamAsync(2); diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs index 9a17dfcb7d76c..e1be280e688bd 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Program.cs @@ -4,6 +4,13 @@ namespace AsyncBreakfast { + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + class Program { static async Task Main(string[] args) @@ -97,7 +104,7 @@ private static async Task FryEggsAsync(int howMany) Console.WriteLine("cooking the eggs ..."); await Task.Delay(3000); Console.WriteLine("Put eggs on plate"); - + return new Egg(); } @@ -107,4 +114,4 @@ private static Coffee PourCoffee() return new Coffee(); } } -} \ No newline at end of file +} diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Bacon.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Bacon.cs deleted file mode 100644 index 28249eaa8d0fb..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Bacon.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Bacon - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Coffee.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Coffee.cs deleted file mode 100644 index a3aa2d8f66eaf..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Coffee.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Coffee - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Egg.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Egg.cs deleted file mode 100644 index ab41cfdd52377..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Egg.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Egg - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Juice.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Juice.cs deleted file mode 100644 index 4e1b7b15fb6d4..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Juice.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace AsyncBreakfast -{ - internal class Juice - { - } -} \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs index 7c4775de6ae17..6cbda6bba519c 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Program.cs @@ -3,6 +3,13 @@ namespace AsyncBreakfast { + // These classes are intentionally empty for the purpose of this example. They are simply marker classes for the purpose of demonstration, contain no properties, and serve no other purpose. + internal class Bacon { } + internal class Coffee { } + internal class Egg { } + internal class Juice { } + internal class Toast { } + class Program { static void Main(string[] args) @@ -32,10 +39,10 @@ private static Juice PourOJ() return new Juice(); } - private static void ApplyJam(Toast toast) => + private static void ApplyJam(Toast toast) => Console.WriteLine("Putting jam on the toast"); - private static void ApplyButter(Toast toast) => + private static void ApplyButter(Toast toast) => Console.WriteLine("Putting butter on the toast"); private static Toast ToastBread(int slices) @@ -85,4 +92,4 @@ private static Coffee PourCoffee() return new Coffee(); } } -} \ No newline at end of file +} diff --git a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Toast.cs b/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Toast.cs deleted file mode 100644 index 037857b2187b5..0000000000000 --- a/docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Toast.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace AsyncBreakfast -{ - internal class Toast - { - } -} \ No newline at end of file