Canceling a parallel query is very similar to canceling a task using TPL. First, we create a cancellation token and then we issue a cancel request to the cancellation token. This will create an operation cancellation exception. Then when we execute our parallel query, add the parallel extension method
WithCancellation(), and pass it the cancellation token. Then, finally, we catch the operation cancellation request and process it.
The .NET framework does not pass a single
OperationCanceledException into a
OperationCanceledException must be processed in a separate
Now, let's open our
PLINQQuery project again and this time we will add a Cancel button and work with the