From 2627192370878b990632f24a86e2e72c349e918c Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 9 Jun 2022 13:46:56 -0400 Subject: [PATCH 1/4] Remove note In favor of updating the example along with the note. --- docs/csharp/programming-guide/concepts/async/index.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/csharp/programming-guide/concepts/async/index.md b/docs/csharp/programming-guide/concepts/async/index.md index bde2cdc82db10..9fa887bcc7d4d 100644 --- a/docs/csharp/programming-guide/concepts/async/index.md +++ b/docs/csharp/programming-guide/concepts/async/index.md @@ -31,9 +31,6 @@ Now, consider those same instructions written as C# statements: 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. From a5cdf29c836956e6c543662c7d7395905d1bbb58 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 9 Jun 2022 13:54:01 -0400 Subject: [PATCH 2/4] Add empty classes to Program.cs file --- .../snippets/index/AsyncBreakfast-V2/Program.cs | 7 +++++++ .../snippets/index/AsyncBreakfast-V3/Program.cs | 9 ++++++++- .../index/AsyncBreakfast-starter/Program.cs | 13 ++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) 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-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-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 +} From 887fcaa3bcc33953433f963f6f347042d6843cee Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 9 Jun 2022 13:54:10 -0400 Subject: [PATCH 3/4] Remove separate files for empty classes --- .../async/snippets/index/AsyncBreakfast-V2/Bacon.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V2/Coffee.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V2/Egg.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V2/Juice.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V2/Toast.cs | 8 -------- .../async/snippets/index/AsyncBreakfast-V3/Bacon.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V3/Coffee.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V3/Egg.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V3/Juice.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-V3/Toast.cs | 8 -------- .../snippets/index/AsyncBreakfast-final/Bacon.cs | 6 ------ .../snippets/index/AsyncBreakfast-final/Coffee.cs | 6 ------ .../async/snippets/index/AsyncBreakfast-final/Egg.cs | 6 ------ .../snippets/index/AsyncBreakfast-final/Juice.cs | 6 ------ .../snippets/index/AsyncBreakfast-final/Program.cs | 11 +++++++++-- .../snippets/index/AsyncBreakfast-final/Toast.cs | 8 -------- .../snippets/index/AsyncBreakfast-starter/Bacon.cs | 6 ------ .../snippets/index/AsyncBreakfast-starter/Coffee.cs | 6 ------ .../snippets/index/AsyncBreakfast-starter/Egg.cs | 6 ------ .../snippets/index/AsyncBreakfast-starter/Juice.cs | 6 ------ .../snippets/index/AsyncBreakfast-starter/Toast.cs | 8 -------- 21 files changed, 9 insertions(+), 130 deletions(-) delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Bacon.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Coffee.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Egg.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Juice.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V2/Toast.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Bacon.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Coffee.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Egg.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Juice.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-V3/Toast.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Bacon.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Coffee.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Egg.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Juice.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-final/Toast.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Bacon.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Coffee.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Egg.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Juice.cs delete mode 100644 docs/csharp/programming-guide/concepts/async/snippets/index/AsyncBreakfast-starter/Toast.cs 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/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/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/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 From 33ebbd19b2cdd9704d45252ace18735f4d8c87cb Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Thu, 9 Jun 2022 13:55:56 -0400 Subject: [PATCH 4/4] update example highlight to include additional empty classes and comment --- docs/csharp/programming-guide/concepts/async/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/programming-guide/concepts/async/index.md b/docs/csharp/programming-guide/concepts/async/index.md index 9fa887bcc7d4d..d38d24a659644 100644 --- a/docs/csharp/programming-guide/concepts/async/index.md +++ b/docs/csharp/programming-guide/concepts/async/index.md @@ -25,7 +25,7 @@ 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":::