U
U
Uncle Seryozha2016-07-02 06:07:27
In contact with
Uncle Seryozha, 2016-07-02 06:07:27

C# webclient.DownloadStringTaskAsync request queue example?

Due to the limit of 3 requests per second, I constantly get a ban for 2.5 seconds. I have all calls to VK in the form of webclient.DownloadStringTaskAsync(...).
Help implement a queue to collect webclient.DownloadStringTaskAsync calls from many concurrent functions into a single queue.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rou1997, 2016-07-02
@Rou1997

When a response comes from one, delay and send the next one.

T
Tsiren Naimanov, 2016-07-02
@ImmortalCAT

По разному можно реализовать...
и ещё какие то конструкции, гуглите, а лучше посмотрите реализацию VK API на github, там называется vknet

A
Andrew Kondratiuk, 2016-07-02
@a1antoo

Alternatively, you can make a class, say, QueuedWebClientand implement the necessary methods for loading data in it, for example, the same DownloadString. In the class, make a static instance Queueand simply add links to the queue by which you need to download data or delegates, where some kind of loading logic is performed. Then, if you do not want to block the main thread, you can use some kind of timer and use it to pull the next element from the queue. You can add an event to the class itself QueuedWebClient, which will be triggered when the downloaded data is ready.
But this is just one of the options.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question