dotnet / dotnet/dotnet-api-docs

Example in AggregateException doc is not work

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

Description

Hi,
I run the example which in [AggregateException doc](https://learn.microsoft.com/en-us/dotnet/api/system.aggregateexception?view=net-7.0&source=docs#examples), the example code did not catch an AggregateException, the following code will not work:
```c#
catch (AggregateException ae)
{
Console.WriteLine("Caught aggregate exception-Task.Wait behavior");
ae.Handle((x) =>
{
if (x is UnauthorizedAccessException) // This we know how to handle.
{
Console.WriteLine("You do not have permission to access all folders in this path.");
Console.WriteLine("See your network administrator or try another path.");
return true;
}
return false; // Let anything else stop the application.
});
}
```

My environment:
+ .net 7.0
+ Win10

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.