dotnet / dotnet/dotnet-api-docs
Misinformation on multi-threaded behavior
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Type of issue
Other (describe below)
### Description
Information given in the article https://learn.microsoft.com/en-us/dotnet/api/system.runtime.exceptionservices.exceptionhandling.raiseappdomainunhandledexceptionevent?view=net-10.0
is not reflected by actual behavior in dotnet 10.
Consider following application
```
using System.Runtime.ExceptionServices;
var exception1 = new Exception("Exception 1");
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
Console.WriteLine("Started handler for " + e.ExceptionObject);
if (e.ExceptionObject == exception1)
Thread.Sleep(5000);
Console.WriteLine("Finished handler for " + e.ExceptionObject);
};
ThreadPool.QueueUserWorkItem(_ =>
{
Thread.Sleep(1000);
ExceptionHandling.RaiseAppDomainUnhandledExceptionEvent(new Exception("Exception 2 from parallel thread"));
Console.WriteLine("Finished calling RaiseAppDomainUnhandledExceptionEvent for exception 2 from parallel thread");
});
ExceptionHandling.RaiseAppDomainUnhandledExceptionEvent(exception1);
Console.WriteLine("Finished calling RaiseAppDomainUnhandledExceptionEvent for exception 1");
```
Which prints
> Started handler for System.Exception: Exception 1
Started handler for System.Exception: Exception 2 from parallel thread
Finished handler for System.Exception: Exception 2 from parallel thread
Finished calling RaiseAppDomainUnhandledExceptionEvent for exception 2 from parallel thread
Finished handler for System.Exception: Exception 1
Finished calling RaiseAppDomainUnhandledExceptionEvent for exception 1
Process finished with exit code 0.
So, no threads have to wait indefinitely and moreover threads don't wait for each other at all.
### Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.runtime.exceptionservices.exceptionhandling.raiseappdomainunhandledexceptionevent?view=net-10.0
### Content source URL
https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System.Runtime.ExceptionServices/ExceptionHandling.xml
### Document Version Independent Id
225e6f33-99c0-49dc-e1c5-6fadd0fdfda2
### Platform Id
242dbdae-3183-c01f-7b66-70ba70aa6b66
### Article author
@dotnet-bot
Contributor guide
Research direction
Start with the API page and its content source, ExceptionHandling.xml, then compare the documented multi-threaded behavior with the reproducible .NET 10 sample in the issue. Update the documentation to match the observed behavior, including the ordering and waiting claims, and verify the rendered article reflects the correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100