rategate

How to change the rate limit whilst using a RateGate?

半城伤御伤魂 提交于 2020-02-04 03:52:27
问题 I am using the concise RateGate class to limit the number of requests I send to a server. My code looks something like this: var RateLimit = 35; using(var RateGate = new RateGate(RateLimit, TimeSpan.FromSeconds(1))) { for(var Run = 1; Run <= 50; Run++) { for(var Batch = 0; Batch < 200; Batch++) { // Do some work, then... MyClass MyClass; if(MyClass.RateLimitHit) { RateLimit--; } RateGate.WaitToProceed(); } } } Inside the if(MyClass.RateLimitHit) , I need to lower the rate limit by 1. Not just