Multithreading + Httpwebrequests

Hello, I’m having a problem with threading and Httpwebrequests.

I have about ~150 requests I need to perform in parallel. A constraint is that I have to use threads (my boss prefers it this way). The threading is fine and works great. Create thread, make request within thread, loop list of threads and run them at the same time.

The problem is that a new “rogue” request might come in at any given time that is high priority. It can come in when the 150 other ones are going.

Right now, what happens is that the rogue request doesn’t fire until the 150 are done. I’ve tried using ManualResetEvent, I’ve tried setting boolean flags, I’ve tried changing the default connection limit in the ServicePointManager…It’s always the same behaviour.

Is there a way I can force this request to fire as soon as it comes in, then resume whatever the 150 threads were up to?

Sorry for the lack of code – this is a work problem so I can’t post anything. It’s proprietary enough that it wouldn’t be that comprehensible on its own anyway.

Thanks for any help!

submitted by /u/LookAtThisRhino
[link] [comments]

Leave a Reply