question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetResultBatchesAsync will run until the infinite

See original GitHub issue

Version

6.1.2

Details

When you call

await foreach (var video in youtube.Search.GetVideosAsync("cicero", token))
{
	// Some code here
}

this can run forever until we want to cancel the token, but what if I want to do some pagination? In that case, when I cancel the method I’ll lose everything else.

So I would like to suggest the support for startPage and endPage, with that the method will execute during the delta between these two values and we can do pagination.

I’ve a code working for this feature, if you want I can submit a PR. Added new overloads to avoid breaking changes and too much modification in the API.

Steps to reproduce

  • Install the package
  • Call using a very popular query
await foreach (var video in youtube.Search.GetVideosAsync("cicero", token))
{
	// Some code here
}
  • It can take forever

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Tyrrrzcommented, Jun 21, 2022
var enumerator = youtube.Playlists.GetVideoBatchesAsync("PLa1F2ddGya_-UvuAqHAksYnB0qL9yWDO6").GetAsyncEnumerator();

while (CheckIfUserWantsToContinue() && await enumerator.MoveNextAsync())
{
    var batch = enumerator.Current;
}
0reactions
pictoscommented, Jun 21, 2022

Thanks @Tyrrrz

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to replace infinite sleep in async code?
I have code in service fabric that init service and wait forever (it is from template generated from VS). I replaced this GetAwaiter().GetResult...
Read more >
In JavaScript, how is awaiting the result of an async ...
In the async version, an await basically just blocks the rest of that function, letting the main loop continue (the part below the...
Read more >
What is the best approach to call asynchronous method ...
With this solution the async method runs on thread from thread pool. Because of that, if it hits await it will have it's...
Read more >
Understanding Control Flow with Async and Await in C# | ...
Again, this is synchronous; no execution will take place on the current thread until GetResult returns with the data returned by the operation...
Read more >
Async return types (C#)
When GetLeisureHoursAsync is called from within an await expression in the ShowTodaysInfo method, the await expression retrieves the integer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found