Method QueryAsync
- Namespace
- GuildWars2
- Assembly
- GuildWars2.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
keysIEnumerable<TKey>The keys for which to retrieve the values.
bulkRequestBulkRequest<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.
degreeOfParallelismintThe maximum number of concurrent requests.
chunkSizeintThe maximum number of keys to retrieve in a single request.
progressIProgress<BulkProgress>An optional progress object to receive progress updates: result count and result total.
cancellationTokenCancellationTokenA token to cancel the request.
Returns
- IAsyncEnumerable<TValue>
The collection of values found.
Type Parameters
TKeyThe data type of the keys.
TValueThe data type of the values.
Exceptions
- ArgumentException
Thrown when the keys collection is empty.
- ArgumentOutOfRangeException
Thrown when
chunkSizeis less than 1 or greater than 200, or whendegreeOfParallelismis less than 1.