AsyncPageable<T> Class
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.
A collection of values that may take multiple service requests to iterate over.
public abstract class AsyncPageable<T> : System.Collections.Generic.IAsyncEnumerable<T>
type AsyncPageable<'T> = class
interface IAsyncEnumerable<'T>
Public MustInherit Class AsyncPageable(Of T)
Implements IAsyncEnumerable(Of T)
Type Parameters
- T
The type of the values.
- Inheritance
-
AsyncPageable<T>
- Implements
Examples
Example of enumerating an AsyncPageable using the async foreach
loop:
// call a service method, which returns AsyncPageable<T>
AsyncPageable<SecretProperties> allSecretProperties = client.GetPropertiesOfSecretsAsync();
await foreach (SecretProperties secretProperties in allSecretProperties)
{
Console.WriteLine(secretProperties.Name);
}
or using a while loop:
// call a service method, which returns AsyncPageable<T>
AsyncPageable<SecretProperties> allSecretProperties = client.GetPropertiesOfSecretsAsync();
IAsyncEnumerator<SecretProperties> enumerator = allSecretProperties.GetAsyncEnumerator();
try
{
while (await enumerator.MoveNextAsync())
{
SecretProperties secretProperties = enumerator.Current;
Console.WriteLine(secretProperties.Name);
}
}
finally
{
await enumerator.DisposeAsync();
}
Constructors
AsyncPageable<T>() |
Initializes a new instance of the AsyncPageable<T> class for mocking. |
AsyncPageable<T>(CancellationToken) |
Initializes a new instance of the AsyncPageable<T> class. |
Properties
CancellationToken |
Gets a CancellationToken used for requests made while enumerating asynchronously. |
Methods
AsPages(String, Nullable<Int32>) |
Enumerate the values a Page<T> at a time. This may make multiple service requests. |
FromPages(IEnumerable<Page<T>>) |
Creates an instance of Pageable<T> using the provided pages. |
GetAsyncEnumerator(CancellationToken) |
Enumerate the values in the collection asynchronously. This may make multiple service requests. |