Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Posts Tagged "threading"

Rate Limited Threading in C#

Jeremy Mill

I recently ran into an issue while working on a project dealing with an external, rate limited, REST API. We wanted to perform an action on several thousand local objects which required hitting this external service and getting back a response. Running in an iterative pattern wasn’t an option for us because it would take too long, and guessing the number to try per minute wasn’t an option either because we might incur extra charges from the provider of the external API. The solution was to create a rate limited ThreadPool in our C# application to perform the requests, and a BlockingCollection to store the responses.