I'm doing some automation using a localhost address, so if a request takes quite a bit of time to process, it's almost guaranteed that it will not complete and will time out. Waiting for that to happen, not being able to make another request at the time is not cool.
I'd like to be able to predict if a request is timing out and cancel it. It's usually completed in under 6ms. I suppose I could use StopWatch
to monitor the time, but how do I continuously check if it's time to cancel current request and start a new one?
Currently, I'm just running a Timer
with 50ms interval and do BeginInvoke
on the update method. When a request times out, my app freezes for a bit, and when several requests in a row time out, freeze times stack and freezing becomes very noticeable. So I thought I should somehow limit simultanous requests to just one at a time and restart it whenever it takes too long, but I have no idea how to code that.