From 9a2cc759f0c6ffe4686152e16844f08429e08165 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Wed, 8 Dec 2021 18:35:49 +0200 Subject: [PATCH 1/3] Fix incorrect exception Fixes https://github.com/dotnet/docs/issues/27308 --- .../concepts/async/cancel-async-tasks-after-a-period-of-time.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md b/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md index 183ff2388df3e..de206871841f7 100644 --- a/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md +++ b/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md @@ -43,7 +43,7 @@ static async Task Main() await SumPageSizesAsync(); } - catch (TaskCanceledException) + catch (OperationCanceledException) { Console.WriteLine("\nTasks cancelled: timed out.\n"); } From f81d032144403cc3961f587bfa39dc4686cdb4a9 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Thu, 9 Dec 2021 10:22:43 +0200 Subject: [PATCH 2/3] Updated explanation --- .../concepts/async/cancel-async-tasks-after-a-period-of-time.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md b/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md index de206871841f7..06114c2197027 100644 --- a/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md +++ b/docs/csharp/programming-guide/concepts/async/cancel-async-tasks-after-a-period-of-time.md @@ -58,7 +58,7 @@ static async Task Main() The updated `Main` method writes a few instructional messages to the console. Within the [try catch](../../../language-reference/keywords/try-catch.md), a call to schedules a cancellation. This will signal cancellation after a period of time. -Next, the `SumPageSizesAsync` method is awaited. If processing all of the URLs occurs faster than the scheduled cancellation, the application ends. However, if the scheduled cancellation is triggered before all of the URLs are processed, a is thrown. +Next, the `SumPageSizesAsync` method is awaited. If processing all of the URLs occurs faster than the scheduled cancellation, the application ends. However, if the scheduled cancellation is triggered before all of the URLs are processed, a is thrown. ### Example application output From 3c573d9f8330940ea4df7005bb2f8115aea8ee52 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Thu, 9 Dec 2021 10:28:29 +0200 Subject: [PATCH 3/3] Updated example --- .../cancel-tasks/cancel-task-after-period-of-time/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/programming-guide/concepts/async/snippets/cancel-tasks/cancel-task-after-period-of-time/Program.cs b/docs/csharp/programming-guide/concepts/async/snippets/cancel-tasks/cancel-task-after-period-of-time/Program.cs index 6b780341e4931..41486960ff6cf 100644 --- a/docs/csharp/programming-guide/concepts/async/snippets/cancel-tasks/cancel-task-after-period-of-time/Program.cs +++ b/docs/csharp/programming-guide/concepts/async/snippets/cancel-tasks/cancel-task-after-period-of-time/Program.cs @@ -47,7 +47,7 @@ static async Task Main() await SumPageSizesAsync(); } - catch (TaskCanceledException) + catch (OperationCanceledException) { Console.WriteLine("\nTasks cancelled: timed out.\n"); }