dotnet / dotnet/dotnet-api-docs

Exception already being thrown

Open
#836 1 comment 0 reactions 0 assignees View on GitHub
area-System.Threading.Tasks dotnet-api/prod Pri2
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

So the Parallel class looks at the CancellationToken [from time to time, that's not specified] to prematurely end the loop. But what happens if the OperationCanceledException was already thrown from within the code executed in parallel, using the same CancellationToken? Will it be caught and handled properly? Or will it be passed on in some form of AggregateException just like any other exception being thrown in Parallel loops? Multiple concurrently running "tasks" might throw that exception at the same time before the loop can end. Some clarification on how I may use the CancellationToken would be helpful.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 7620a94b-fde4-4d61-904d-3ff319427c38
* Version Independent ID: c8805d8a-332c-ad1a-1e8d-dd10daf1b59e
* Content: [ParallelOptions.CancellationToken Property (System.Threading.Tasks)](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.paralleloptions.cancellationtoken?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Threading.Tasks.ParallelOptions.CancellationToken);k(DevLang-csharp)%26rd%3Dtrue%26f%3D255%26MSPPError%3D-2147217396&view=netframework-4.7.2)
* Content Source: [xml/System.Threading.Tasks/ParallelOptions.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Threading.Tasks/ParallelOptions.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

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.