ParallelEnumerable.WithCancellation(Of TSource) Method (ParallelQuery(Of TSource), CancellationToken)
.NET Framework (current version)
Sets the CancellationToken to associate with the query.
Assembly: System.Core (in System.Core.dll)
<ExtensionAttribute> Public Shared Function WithCancellation(Of TSource) ( source As ParallelQuery(Of TSource), cancellationToken As CancellationToken ) As ParallelQuery(Of TSource)
Parameters
- source
-
Type:
System.Linq.ParallelQuery(Of TSource)
A ParallelQuery on which to set the option.
- cancellationToken
-
Type:
System.Threading.CancellationToken
A cancellation token.
Return Value
Type: System.Linq.ParallelQuery(Of TSource)ParallelQuery representing the same query as source, but with the registered cancellation token.
Type Parameters
- TSource
The type of elements of source.
| Exception | Condition |
|---|---|
| ObjectDisposedException | The CancellationTokenSource associated with the cancellationToken has been disposed. |
| ArgumentNullException | source is a null reference (Nothing in Visual Basic). |
| InvalidOperationException | WithCancellation is used multiple times in the query. |
Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Show: