Table of Contents

Method QueryAsync

Namespace
GuildWars2
Assembly
GW2SDK.dll

QueryAsync<TKey, TValue>(IEnumerable<TKey>, BulkRequest<TKey, TValue>, int, int, IProgress<BulkProgress>?, CancellationToken)

Retrieves bulk data from the Guild Wars 2 API.
Given a large collection of keys, this method will the collection into smaller chunks and query the API for each chunk. The chunk size can optionally be specified, otherwise the maximum chunk size (200) is used.
Chunks are queried in parallel by default. The results are streamed as they become available, ordered by completion. The degree of parallelism can optionally be specified (default: 20). You can optionally specify a progress object to receive progress updates.

public static IAsyncEnumerable<TValue> QueryAsync<TKey, TValue>(IEnumerable<TKey> keys, BulkRequest<TKey, TValue> bulkRequest, int degreeOfParallelism = 20, int chunkSize = 200, IProgress<BulkProgress>? progress = null, CancellationToken cancellationToken = default)

Parameters

keys IEnumerable<TKey>

The keys for which to retrieve the values.

bulkRequest BulkRequest<TKey, TValue>

The method that takes a set of keys and retrieves the corresponding values. The method must be thread-safe. The method must not return null, duplicate values, values that do not correspond to the keys. The method may return values out of order or return fewer values than the number of keys.

degreeOfParallelism int

The maximum number of concurrent requests.

chunkSize int

The maximum number of keys to retrieve in a single request.

progress IProgress<BulkProgress>

An optional progress object to receive progress updates: result count and result total.

cancellationToken CancellationToken

A token to cancel the request.

Returns

IAsyncEnumerable<TValue>

The collection of values found.

Type Parameters

TKey

The data type of the keys.

TValue

The data type of the values.

Exceptions

ArgumentException

Thrown when the keys collection is empty.

ArgumentOutOfRangeException

Thrown when chunkSize is less than 1 or greater than 200, or when degreeOfParallelism is less than 1.