@@ -173,7 +173,7 @@ public IAsyncEnumerator<T> GetEnumerator(int limitPerRequest, int maximumLimit =
173
173
}
174
174
175
175
/// <inheritdoc/>
176
- public IAsyncEnumerator < T > GetEnumerator ( )
176
+ public IAsyncEnumerator < T > GetAsyncEnumerator ( CancellationToken cancellationToken = default )
177
177
{
178
178
return GetEnumerator ( LimitPerRequest , MaximumLimit , IsStream ) ;
179
179
}
@@ -365,26 +365,25 @@ private void Parse(JToken json)
365
365
Before = json [ "data" ] [ "before" ] . Value < string > ( ) ;
366
366
}
367
367
368
- public void Dispose ( )
368
+ public ValueTask DisposeAsync ( )
369
369
{
370
- // ...
370
+ return default ;
371
371
}
372
372
373
- public async Task < bool > MoveNext ( CancellationToken cancellationToken )
373
+ public async ValueTask < bool > MoveNextAsync ( )
374
374
{
375
375
if ( stream )
376
376
{
377
- return await MoveNextForwardAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
377
+ return await MoveNextForwardAsync ( ) . ConfigureAwait ( false ) ;
378
378
}
379
379
else
380
380
{
381
- return await MoveNextBackAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
381
+ return await MoveNextBackAsync ( ) . ConfigureAwait ( false ) ;
382
382
}
383
383
}
384
384
385
- private async Task < bool > MoveNextBackAsync ( CancellationToken cancellationToken )
385
+ private async Task < bool > MoveNextBackAsync ( )
386
386
{
387
- cancellationToken . ThrowIfCancellationRequested ( ) ;
388
387
if ( CurrentIndex == - 1 )
389
388
{
390
389
//first call, get a page and set CurrentIndex
@@ -421,7 +420,7 @@ private async Task<bool> MoveNextBackAsync(CancellationToken cancellationToken)
421
420
return true ;
422
421
}
423
422
424
- private async Task < bool > MoveNextForwardAsync ( CancellationToken cancellationToken )
423
+ private async Task < bool > MoveNextForwardAsync ( )
425
424
{
426
425
CurrentIndex ++ ;
427
426
@@ -435,7 +434,6 @@ private async Task<bool> MoveNextForwardAsync(CancellationToken cancellationToke
435
434
int tries = 0 ;
436
435
while ( true )
437
436
{
438
- cancellationToken . ThrowIfCancellationRequested ( ) ;
439
437
tries ++ ;
440
438
441
439
try
@@ -446,7 +444,7 @@ private async Task<bool> MoveNextForwardAsync(CancellationToken cancellationToke
446
444
catch ( Exception ex )
447
445
{
448
446
// sleep for a while to see if we can recover
449
- await Sleep ( tries , cancellationToken , ex ) . ConfigureAwait ( false ) ;
447
+ await Sleep ( tries , ex ) . ConfigureAwait ( false ) ;
450
448
}
451
449
452
450
// the page is only populated if there are *new* items to yielded from the listing.
@@ -456,14 +454,14 @@ private async Task<bool> MoveNextForwardAsync(CancellationToken cancellationToke
456
454
}
457
455
458
456
// No listings were returned in the page.
459
- await Sleep ( tries , cancellationToken ) . ConfigureAwait ( false ) ;
457
+ await Sleep ( tries ) . ConfigureAwait ( false ) ;
460
458
}
461
459
}
462
460
Count ++ ;
463
461
return true ;
464
462
}
465
463
466
- private async Task Sleep ( int tries , CancellationToken cancellationToken , Exception ex = null )
464
+ private async Task Sleep ( int tries , Exception ex = null )
467
465
{
468
466
// wait up to 3 minutes between tries
469
467
// TODO: Make this configurable
@@ -481,7 +479,7 @@ private async Task Sleep(int tries, CancellationToken cancellationToken, Excepti
481
479
{
482
480
seconds = tries * 5 ;
483
481
}
484
- await Task . Delay ( seconds * 1000 , cancellationToken ) . ConfigureAwait ( false ) ;
482
+ await Task . Delay ( seconds * 1000 ) . ConfigureAwait ( false ) ;
485
483
}
486
484
}
487
485
#pragma warning restore
0 commit comments