Skip to content

Commit b471df1

Browse files
authored
Added cautionary alert to address concerns in #29010 (#29767)
1 parent 847ccc1 commit b471df1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/standard/parallel-programming/exception-handling-task-parallel-library.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Exception handling (Task Parallel Library)"
33
description: Explore exception handling using the Task Parallel Library (TPL) in .NET. See nested aggregate exceptions, inner exceptions, unobserved task exceptions, & more.
4-
ms.date: 05/06/2022
4+
ms.date: 06/08/2022
55
dev_langs:
66
- "csharp"
77
- "vb"
@@ -27,6 +27,9 @@ If you do not want to call the <xref:System.Threading.Tasks.Task.Wait%2A?display
2727
[!code-csharp[TPL_Exceptions#29](../../../samples/snippets/csharp/VS_Snippets_Misc/tpl_exceptions/cs/handling22.cs#29)]
2828
[!code-vb[TPL_Exceptions#29](../../../samples/snippets/visualbasic/VS_Snippets_Misc/tpl_exceptions/vb/handling22.vb#29)]
2929

30+
> [!CAUTION]
31+
> The preceding example code includes a `while` loop that polls the task's <xref:System.Threading.Tasks.Task.IsCompleted%2A?displayProperty=nameWithType> property to determine when the task has completed. This should never be done in production code as it is very inefficient.
32+
3033
If you do not wait on a task that propagates an exception, or access its <xref:System.Threading.Tasks.Task.Exception%2A> property, the exception is escalated according to the .NET exception policy when the task is garbage-collected.
3134

3235
When exceptions are allowed to bubble up back to the joining thread, it is possible that a task may continue to process some items after the exception is raised.

0 commit comments

Comments
 (0)