示例#1
0
        async IAsyncEnumerable <ListPartsResponse> IPaginator <ListPartsResponse> .PaginateAsync(CancellationToken cancellationToken = default)
        {
            if (Interlocked.Exchange(ref _isPaginatorInUse, 1) != 0)
            {
                throw new System.InvalidOperationException("Paginator has already been consumed and cannot be reused. Please create a new instance.");
            }
            var marker = _request.Marker;
            ListPartsResponse response;

            do
            {
                _request.Marker = marker;
                response        = await _client.ListPartsAsync(_request, cancellationToken).ConfigureAwait(false);

                marker = response.Marker;
                cancellationToken.ThrowIfCancellationRequested();
                yield return(response);
            }while (marker != null);
        }