2 ms·
I personally used a semaphore for that. You create a semaphore with an initial count of MAX_REQS_PER_SECOND, create WORKER_COUNT of looping "worker" tasks that
by Joker_vD 5y ago
I personally used a semaphore for that. You create a semaphore with an initial count of MAX_REQS_PER_SECOND, create WORKER_COUNT of looping "worker" tasks that each call WaitAsync() on that semaphore before doing request (and don't call Release() after request is done), plus a separate task that does either
Sleep(100);
Release(MAX_REQS_PER_SECOND / 10);
or
Sleep(1000 * WORKER_COUNT / MAX_REQS_PER_SECOND);
Release(WORKER_COUNT);
in a loop, depending on what numbers make more sense.
- deleted 5y ago[deleted]