protected static async Task <IApiResult <IEnumerable <T> > > RetrieveCursoredResult <T>(IApiAccessor accessor, Func <IApiAccessor, long, Task <IApiResult <ICursorResult <IEnumerable <T> > > > > func, Action <Exception> exceptionHandler, CancellationToken token) { var resultList = new List <T>(); CursorResultExtension.ApiContinuationReader <IEnumerable <T> > reader = () => accessor.ReadCursorApi(func, token); var lastRateLimit = RateLimitDescription.Empty; while (reader != null) { try { var result = await reader().ConfigureAwait(false); resultList.AddRange(result.Item1.Result); lastRateLimit = result.Item1.RateLimit; reader = result.Item2; } catch (Exception ex) { exceptionHandler(ex); break; } } return(ApiResult.Create(resultList, lastRateLimit)); }