dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
702 stars 1.55k forks source link

Running Example code causes an exception #10309

Open WalterGoy opened 3 weeks ago

WalterGoy commented 3 weeks ago

Type of issue

Code doesn't work

Description

When this example is run, an this exception --- System.OperationCanceledException: 'The operation was canceled.' --- is thrown. When this line --- //token.ThrowIfCancellationRequested(); --- is commented out, the example runs.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskstatus?view=net-8.0#system-threading-tasks-taskstatus-created

Content source URL

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

Document Version Independent Id

8a50e248-3e54-65d8-e726-48b23a07265e

Article author

@dotnet-bot

dotnet-policy-service[bot] commented 3 weeks ago

Tagging subscribers to this area: @dotnet/area-system-threading-tasks

rzikm commented 2 weeks ago

The exception is supposed to be thrown, and wrapped in AggregateException and caught in the catch block in the code example.

When you run the code, is the output of the program significantly different form the example output given in the code snippet?