ParallelEnumerable.TakeWhile 方法

定义

只要指定的条件为 true,就会返回并行序列的元素。Returns elements from a parallel sequence as long as a specified condition is true.

重载

TakeWhile<TSource>(ParallelQuery<TSource>, Func<TSource,Int32,Boolean>)

只要指定的条件为 true,就会返回并行序列的元素。Returns elements from a parallel sequence as long as a specified condition is true. 将在谓词函数的逻辑中使用元素的索引。The element's index is used in the logic of the predicate function.

TakeWhile<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>)

只要指定的条件为 true,就会返回并行序列的元素。Returns elements from a parallel sequence as long as a specified condition is true.

TakeWhile<TSource>(ParallelQuery<TSource>, Func<TSource,Int32,Boolean>)

只要指定的条件为 true,就会返回并行序列的元素。Returns elements from a parallel sequence as long as a specified condition is true. 将在谓词函数的逻辑中使用元素的索引。The element's index is used in the logic of the predicate function.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TSource> ^ TakeWhile(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, int, bool> ^ predicate);
public static System.Linq.ParallelQuery<TSource> TakeWhile<TSource> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,int,bool> predicate);
static member TakeWhile : System.Linq.ParallelQuery<'Source> * Func<'Source, int, bool> -> System.Linq.ParallelQuery<'Source>
<Extension()>
Public Function TakeWhile(Of TSource) (source As ParallelQuery(Of TSource), predicate As Func(Of TSource, Integer, Boolean)) As ParallelQuery(Of TSource)

类型参数

TSource

source 的元素类型。The type of elements of source.

参数

source
ParallelQuery<TSource>

要从其返回元素的序列。The sequence to return elements from.

predicate
Func<TSource,Int32,Boolean>

用于测试每个源元素是否满足条件的函数;该函数的第二个参数表示源元素的索引。A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

返回

ParallelQuery<TSource>

一个序列,它包含输入序列中出现在无法再通过测试的元素之前的元素。A sequence that contains elements from the input sequence that occur before the element at which the test no longer passes.

例外

sourcepredicate 为 null 引用(在 Visual Basic 中为 Nothing)。source or predicate is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

超过 MaxValue 个元素都是用这个查询枚举的。More than MaxValue elements are enumerated by this query.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

适用于

TakeWhile<TSource>(ParallelQuery<TSource>, Func<TSource,Boolean>)

只要指定的条件为 true,就会返回并行序列的元素。Returns elements from a parallel sequence as long as a specified condition is true.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TSource> ^ TakeWhile(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, bool> ^ predicate);
public static System.Linq.ParallelQuery<TSource> TakeWhile<TSource> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,bool> predicate);
static member TakeWhile : System.Linq.ParallelQuery<'Source> * Func<'Source, bool> -> System.Linq.ParallelQuery<'Source>
<Extension()>
Public Function TakeWhile(Of TSource) (source As ParallelQuery(Of TSource), predicate As Func(Of TSource, Boolean)) As ParallelQuery(Of TSource)

类型参数

TSource

source 的元素类型。The type of elements of source.

参数

source
ParallelQuery<TSource>

要从其返回元素的序列。The sequence to return elements from.

predicate
Func<TSource,Boolean>

用于测试每个元素是否满足条件的函数。A function to test each element for a condition.

返回

ParallelQuery<TSource>

一个序列,它包含输入序列中出现在无法再通过测试的元素之前的元素。A sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.

例外

sourcepredicate 为 null 引用(在 Visual Basic 中为 Nothing)。source or predicate is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

适用于