AsyncEnumerable.LongCountAsync Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
LongCountAsync<TSource>(IAsyncEnumerable<TSource>, CancellationToken) |
Returns the number of elements in a sequence satisfy a condition. |
LongCountAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Boolean>, CancellationToken) |
Returns the number of elements in a sequence satisfy a condition. |
LongCountAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<Boolean>>, CancellationToken) |
Returns the number of elements in a sequence satisfy a condition. |
- Source:
- CountAsync.cs
Returns the number of elements in a sequence satisfy a condition.
public static System.Threading.Tasks.ValueTask<long> LongCountAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, System.Threading.CancellationToken cancellationToken = default);
static member LongCountAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int64>
<Extension()>
Public Function LongCountAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Long)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
- IAsyncEnumerable<TSource>
A sequence that contains elements to be tested and counted.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
The number of elements in the input sequence that satisfy the condition in the predicate function.
Exceptions
source
is null
.
Applies to
.NET 10 and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided), 10 |
.NET Standard | 2.0 (package-provided) |
- Source:
- CountAsync.cs
Returns the number of elements in a sequence satisfy a condition.
public static System.Threading.Tasks.ValueTask<long> LongCountAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,bool> predicate, System.Threading.CancellationToken cancellationToken = default);
static member LongCountAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, bool> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int64>
<Extension()>
Public Function LongCountAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, Boolean), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Long)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
- IAsyncEnumerable<TSource>
A sequence that contains elements to be tested and counted.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
The number of elements in the input sequence that satisfy the condition in the predicate function.
Exceptions
source
is null
.
Applies to
.NET 10 and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided), 10 |
.NET Standard | 2.0 (package-provided) |
LongCountAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<Boolean>>, CancellationToken)
- Source:
- CountAsync.cs
Returns the number of elements in a sequence satisfy a condition.
public static System.Threading.Tasks.ValueTask<long> LongCountAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<bool>> predicate, System.Threading.CancellationToken cancellationToken = default);
static member LongCountAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<bool>> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int64>
<Extension()>
Public Function LongCountAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, CancellationToken, ValueTask(Of Boolean)), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Long)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
- IAsyncEnumerable<TSource>
A sequence that contains elements to be tested and counted.
- predicate
- Func<TSource,CancellationToken,ValueTask<Boolean>>
A function to test each element for a condition.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
The number of elements in the input sequence that satisfy the condition in the predicate function.
Exceptions
source
is null
.
Applies to
.NET 10 and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided), 10 |
.NET Standard | 2.0 (package-provided) |
.NET feedback
.NET is an open source project. Select a link to provide feedback: