dotnet / dotnet/dotnet-api-docs

Documentation for TaskScheduler.ThrowUnobservedTaskExceptions is messed up.

Open
#11,828 1 comment 2 reactions 0 assignees View on GitHub
area-System.Threading.Tasks untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Type of issue

Other (describe below)

### Description

We were having a debate about relying on the behavior of throwing a task from an deliberately abandoned async task call. That is:

```
async Task Method();

Method(); // Don't wait for it to finish
```

This appears to be the primary documentation for what should happen, and it's talking out both sides of its mouth

"Occurs when a faulted task's unobserved exception is about to trigger exception escalation policy, which, by default, would terminate the process."

but

"To make it easier for developers to write asynchronous code based on tasks, unobserved exceptions raise the [UnobservedTaskException](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskscheduler.unobservedtaskexception?view=net-9.0#system-threading-tasks-taskscheduler-unobservedtaskexception) exception, but the process does not terminate by default."

In addition, the XML fragment is not applicable to .NET Runtime but only .NET Framework.

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskscheduler.unobservedtaskexception?view=net-9.0

### Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Threading.Tasks/TaskScheduler.xml

### Document Version Independent Id

90bccf92-03c1-3825-ef4d-8cb8de33a9d7

### Platform Id

a8b0bf93-f99f-7e0a-4aed-18fa354aa7b8

### Article author

@dotnet-bot

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.