From 83f1c0450ed4361e954edb26a24bd47c448bc867 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 28 Nov 2024 18:12:16 -0800 Subject: [PATCH] Update 19.02 --- Errata.md | 3 ++- src/Chapter19/Listing19.02.PollingATask.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Errata.md b/Errata.md index 12a6ba3f0..31d97ace9 100644 --- a/Errata.md +++ b/Errata.md @@ -41,4 +41,5 @@ Zhou Jing | 22 | 1065 - 1066 | Changed 'Thread' to 'Task' and "Application exiti Zhou Jing | 4 | 161 | Fix `input < 9` to `input < 0` in Listing 4.24 Zhou Jing | 4 | 119 | Show inconsistent size multi-dimensional array in listing 3.16 Zhou Jing | 3 | 114 | Replace `second` with `third` in "// Retrieve third item from the end (Python)" -Tyler Woody | 13 | 702 | Remove the `!` negation in `string.IsNullOrWhiteSpace(input)` in the while loop to properly allow looping \ No newline at end of file +Tyler Woody | 13 | 702 | Remove the `!` negation in `string.IsNullOrWhiteSpace(input)` in the while loop to properly allow looping +Benjamin Michaelis | 19 | .. | Add a `(` before the `next + 1` to complete the parenthesis. \ No newline at end of file diff --git a/src/Chapter19/Listing19.02.PollingATask.cs b/src/Chapter19/Listing19.02.PollingATask.cs index 186b31f8e..7a2993785 100644 --- a/src/Chapter19/Listing19.02.PollingATask.cs +++ b/src/Chapter19/Listing19.02.PollingATask.cs @@ -1,9 +1,9 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter19.Listing19_02; +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter19.Listing19_02; #region INCLUDE using System; using System.Threading.Tasks; -using AddisonWesley.Michaelis.EssentialCSharp.Shared; +using AddisonWesley.Michaelis.EssentialCSharp.Shared; // EXCLUDE public class Program { @@ -17,10 +17,10 @@ public static void Main() #endregion HIGHLIGHT () => PiCalculator.Calculate(100)); - foreach( + foreach ( char busySymbol in Utility.BusySymbols()) { - if(task.IsCompleted) + if (task.IsCompleted) { Console.Write('\b'); break; @@ -55,15 +55,15 @@ public static IEnumerable BusySymbols() { string busySymbols = @"-\|/-\|/"; int next = 0; - while(true) + while (true) { yield return busySymbols[next]; - next = next + 1) % busySymbols.Length; + next = (next + 1) % busySymbols.Length; yield return '\b'; } } } - #region EXCLUDE +#region EXCLUDE */ #endregion EXCLUDE #endregion INCLUDE