Language

AsyncPageable Class

Definition

A collection of values that may take multiple service requests to iterate over.

public abstract class AsyncPageable : System.Collections.Generic.IAsyncEnumerable
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
Implements

Examples

Example of enumerating an AsyncPageable using the async foreach loop:

// call a service method, which returns AsyncPageable
AsyncPageable 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
AsyncPageable allSecretProperties = client.GetPropertiesOfSecretsAsync();

IAsyncEnumerator enumerator = allSecretProperties.GetAsyncEnumerator();
try
{
    while (await enumerator.MoveNextAsync())
    {
        SecretProperties secretProperties = enumerator.Current;
        Console.WriteLine(secretProperties.Name);
    }
}
finally
{
    await enumerator.DisposeAsync();
}

Constructors

Name Description
AsyncPageable()

Initializes a new instance of the AsyncPageable class for mocking.

AsyncPageable(CancellationToken)

Initializes a new instance of the AsyncPageable class.

Properties

Name Description
CancellationToken

Gets a CancellationToken used for requests made while enumerating asynchronously.

Methods

Name Description
AsPages(String, Nullable)

Enumerate the values a Page at a time. This may make multiple service requests.

FromPages(IEnumerable>)

Creates an instance of Pageable using the provided pages.

GetAsyncEnumerator(CancellationToken)

Enumerate the values in the collection asynchronously. This may make multiple service requests.

Applies to