Additional Tech Edit revisions
MODIFY
src/Chapter20/Listing20.01.SynchronousWebRequestHighLatency.cs
src/Chapter20/Listing20.01.SynchronousWebRequestHighLatency.cs
@@ -7,6 +7,30 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter20.Listing20_01
static public class Program
{
+ public static void Main(string[] args)
+ {
+ if (args.Length == 0)
+ {
+ Console.WriteLine("ERROR: No findText argument specified.");
+ return;
+ }
+ string findText = args[0];
+ Console.WriteLine($"Searching for {findText}...");
+
+ string url = "http://www.IntelliTect.com";
+ if (args.Length > 1)
+ {
+ url = args[1];
+ // Ignore additional parameters
+ }
+ Console.Write(url);
+
+ Console.WriteLine("Searching...");
+ int textOccurrenceCount =
+ FindTextInWebUri(findText, url);
+
+ Console.WriteLine(textOccurrenceCount);
+ }
public static int FindTextInWebUri(
string findText, string url)
@@ -57,29 +81,5 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter20.Listing20_01
return textOccurrenceCount;
}
-
- public static void Main(string[] args)
- {
- if (args.Length == 0)
- {
- Console.WriteLine("ERROR: No findText argument specified.");
- return;
- }
- string findText = args[0];
- Console.WriteLine($"Searching for {findText}...");
-
- string url = "http://www.IntelliTect.com";
- if (args.Length > 1)
- {
- url = args[1];
- // Ignore additional parameters
- }
- Console.Write(url);
-
- int occurences =
- FindTextInWebUri(findText, url);
-
- Console.WriteLine(occurences);
- }
}
}

MODIFY
src/Chapter20/Listing20.02.AsynchronousHighLatencyUsingTaskAsynchronyPattern.cs
src/Chapter20/Listing20.02.AsynchronousHighLatencyUsingTaskAsynchronyPattern.cs
@@ -39,9 +39,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter20.Listing20_02
Console.WriteLine("Searching...");
- int occurrences = await task;
+ int textOccurrenceCount = await task;
- Console.WriteLine(occurrences);
+ Console.WriteLine(textOccurrenceCount);
}
public async static Task<int> FindTextInWebUriAsync(
@@ -96,22 +96,8 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter20.Listing20_02
}
}
while (length != 0);
- return textOccurrenceCount;
- }
-
- static public string FormatBytes(long bytes)
- {
- string[] magnitudes =
- new string[] { "GB", "MB", "KB", "Bytes" };
- long max =
- (long)Math.Pow(1024, magnitudes.Length);
-
- return string.Format("{1:##.##} {0}",
- magnitudes.FirstOrDefault(
- magnitude =>
- bytes > (max /= 1024)) ?? "0 Bytes",
- (decimal)bytes / (decimal)max);
+ return textOccurrenceCount;
}
}
}

Additional Tech Edit revisions