Skip to content

Commit 10bc0ab

Browse files
committed
Only Increment CurrentPageIndex if Source.GetPagedItemsAsync's task completes with RanToCompletion
1 parent 529624c commit 10bc0ab

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Microsoft.Toolkit.Uwp/IncrementalLoadingCollection/IncrementalLoadingCollection.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,18 @@ public Task RefreshAsync()
226226
/// </returns>
227227
protected virtual async Task<IEnumerable<IType>> LoadDataAsync(CancellationToken cancellationToken)
228228
{
229-
var result = await Source.GetPagedItemsAsync(CurrentPageIndex++, ItemsPerPage, cancellationToken);
229+
var result = await Source.GetPagedItemsAsync(CurrentPageIndex, ItemsPerPage, cancellationToken)
230+
.ContinueWith(
231+
t =>
232+
{
233+
if (t.Status == TaskStatus.RanToCompletion)
234+
{
235+
CurrentPageIndex += 1;
236+
}
237+
238+
return t.Result;
239+
}, cancellationToken);
240+
230241
return result;
231242
}
232243

0 commit comments

Comments
 (0)