ParallelEnumerable.WithCancellation<TSource>(ParallelQuery<TSource>, CancellationToken) Metodo

Definizione

Imposta l'oggetto CancellationToken da associare alla query.Sets the CancellationToken to associate with the query.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TSource> ^ WithCancellation(System::Linq::ParallelQuery<TSource> ^ source, System::Threading::CancellationToken cancellationToken);
public static System.Linq.ParallelQuery<TSource> WithCancellation<TSource> (this System.Linq.ParallelQuery<TSource> source, System.Threading.CancellationToken cancellationToken);
static member WithCancellation : System.Linq.ParallelQuery<'Source> * System.Threading.CancellationToken -> System.Linq.ParallelQuery<'Source>
<Extension()>
Public Function WithCancellation(Of TSource) (source As ParallelQuery(Of TSource), cancellationToken As CancellationToken) As ParallelQuery(Of TSource)

Parametri di tipo

TSource

Tipo degli elementi di source.The type of elements of source.

Parametri

source
ParallelQuery<TSource>

Oggetto ParallelQuery su cui impostare l'opzione.A ParallelQuery on which to set the option.

cancellationToken
CancellationToken

Token di annullamento.A cancellation token.

Restituisce

ParallelQuery<TSource>

Oggetto ParallelQuery che rappresenta la stessa query come origine, ma con il token di annullamento registrato.ParallelQuery representing the same query as source, but with the registered cancellation token.

Eccezioni

L'oggetto CancellationTokenSource associato all'oggetto cancellationToken è stato eliminato.The CancellationTokenSource associated with the cancellationToken has been disposed.

source è un riferimento null (Nothing in Visual Basic).source is a null reference (Nothing in Visual Basic).

WithCancellation viene utilizzato più volte nella query.WithCancellation is used multiple times in the query.

Si applica a

Vedi anche