AsyncEnumerable.AnyAsync Method
Definition
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.
Overloads
AnyAsync<TSource>(IAsyncEnumerable<TSource>, CancellationToken) |
Determines whether a sequence contains any elements. |
AnyAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Boolean>, CancellationToken) |
Determines whether any element of a sequence satisfies a condition. |
AnyAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<Boolean>>, CancellationToken) |
Determines whether any element of a sequence satisfies a condition. |
AnyAsync<TSource>(IAsyncEnumerable<TSource>, CancellationToken)
- Source:
- AnyAsync.cs
Determines whether a sequence contains any elements.
public static System.Threading.Tasks.ValueTask<bool> AnyAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, System.Threading.CancellationToken cancellationToken = default);
static member AnyAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<bool>
<Extension()>
Public Function AnyAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Boolean)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
- IAsyncEnumerable<TSource>
The IAsyncEnumerable<T> to check for emptiness.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
true if the source sequence contains any elements; otherwise, false.
Exceptions
source
is null
.
Applies to
AnyAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Boolean>, CancellationToken)
- Source:
- AnyAsync.cs
Determines whether any element of a sequence satisfies a condition.
public static System.Threading.Tasks.ValueTask<bool> AnyAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,bool> predicate, System.Threading.CancellationToken cancellationToken = default);
static member AnyAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, bool> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<bool>
<Extension()>
Public Function AnyAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, Boolean), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Boolean)
Type Parameters
- TSource
Parameters
- source
- IAsyncEnumerable<TSource>
An IAsyncEnumerable<T> whose elements to apply the predicate to.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
true if the source sequence is not empty and at least one of its elements passes the test in the specified predicate; otherwise, false.
Exceptions
predicate
is null
.
Applies to
AnyAsync<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<Boolean>>, CancellationToken)
- Source:
- AnyAsync.cs
Determines whether any element of a sequence satisfies a condition.
public static System.Threading.Tasks.ValueTask<bool> AnyAsync<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 AnyAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<bool>> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<bool>
<Extension()>
Public Function AnyAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, CancellationToken, ValueTask(Of Boolean)), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Boolean)
Type Parameters
- TSource
Parameters
- source
- IAsyncEnumerable<TSource>
An IAsyncEnumerable<T> whose elements to apply the predicate to.
- 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
true if the source sequence is not empty and at least one of its elements passes the test in the specified predicate; otherwise, false.
Exceptions
predicate
is null
.