I have a process that iterates through some pages, and is taking around 40seconds. I’d like to display a progress indication, but I don’t have any way of knowing Pager.Pages.Count As I’m filtering by ObjectIds in my BatchGet() I thought I could estimate by knowing how many ObjectIds I had processed, but that doesn’t work either as the results aren’t sorted by ObjectId.
Iterating through all the pages first is majority of the time, so doesn’t work to do that to get count.
For an example
IEnumerable<string> classItemIds = classes.Select(c => c.SquareID);
Pager<InventoryChange> invChanges = await _client.Inventory.BatchGetChangesAsync(
new BatchRetrieveInventoryChangesRequest()
{
CatalogObjectIds = classItemIds,
LocationIds = [LocationId],
});
await foreach (var page in invChanges.AsPagesAsync())
{
//Report back Page#/TotalPages
foreach (var item in page.Items)
{
...
}
}