The brackets in your last call ContinueWithare incorrect:
.ContinueWith(t =>
Console.WriteLine(
"Should not be executed. Task status = " + t.Status,
TaskContinuationOptions.NotOnCanceled));
TaskContinuationOptions.NotOnCanceledpassed as an argument WriteLine.
Fixed
.ContinueWith(t =>
Console.WriteLine(
"Should not be executed. Task status = " + t.Status),
TaskContinuationOptions.NotOnCanceled);
source
share