Ch. 19 code changes
MODIFY
src/Chapter19/Listing19.02.PollingATask.cs
src/Chapter19/Listing19.02.PollingATask.cs
}
}
}
+ #region EXCLUDE
+ /*
+ #endregion EXCLUDE
+ *
+ #region EXCLUDE
+ */
+ #endregion EXCLUDE
#endregion INCLUDE
}
\ No newline at end of file

MODIFY
src/Chapter19/Listing19.07.RegisteringForUnhandledExceptions.cs
src/Chapter19/Listing19.07.RegisteringForUnhandledExceptions.cs
#region HIGHLIGHT
// Register a callback to receive notifications
// of any unhandled exception
- #endregion HIGHLIGHT
- #region EXCLUDE
-#if NETCOREAPP1_1
- System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (s, e) =>
- {
- Message("Event handler starting");
- resetEvent.Set();
- };
-
- void Work()
- {
- Task task = Task.Factory.StartNew(() =>
- {
- Message("Throwing exception.");
- throw new Exception();
- });
- }
- Work();
- Task.Delay(5000);
- GC.Collect();
- GC.WaitForPendingFinalizers();
- GC.Collect();
-
- Action<object, EventArgs> unhandledExcpetionHandler = (s, e) =>
- {
- Message("Event handler starting");
- Delay(4000);
- };
-#else
-#endregion EXCLUDE
- #region HIGHLIGHT
AppDomain.CurrentDomain.UnhandledException +=
(s, e) =>
{
throw new Exception();
});
thread.Start();
- #region EXCLUDE
-#endif
-#if DEBUG1
- resetEvent.Wait();
- {
- if (!resetEvent.Wait(5000))
- {
- throw new Exception("Timed out waiting for unhandled exception.");
- }
-#endif // DEBUG
- #endregion EXCLUDE
+
Delay(2000);
}
finally

MODIFY
src/Chapter19/Listing19.09.UsingTaskRun.cs
src/Chapter19/Listing19.09.UsingTaskRun.cs
private static string CalculatePi(int digits)
{
- // ...
-
+ #region EXCLUDE
return string.Empty;
+ #endregion EXCLUDEe
}
#endregion INCLUDE
}

Ch. 19 code changes