First of all, I would be skeptical of any claims that you will see significant improvements, because you create your HttpWebRequest special way. The bottleneck for single-threaded requests like yours will be network latency and server response time. (Perhaps they do most of the server processing before responding to your request).
You are making a lock request, which means your processor is not doing anything while it is waiting for a response.
If you want to use a multi-threaded application, you can do something like the following:
var tasks = new Task[10]; for (int i = 0; i < 10; i++) { tasks[i] = Task.Factory.StartNew(() => { int messages_sent_by_one_task = 0; while(messages_sent_by_one_task < 10) { QuickSend(); messages_sent_by_one_task++; } }); } while (tasks.Any(t => !t.IsCompleted)) { }
This will trigger 10 tasks, each of which will send 10 messages. If one answer takes a long time, the remaining 9 threads will continue to rejoice.
I believe that you can probably improve this, you should have included asynchronous requests and HTTPClient , so each of your 10 threads has never been blocked. However, I do not feel ready to give an example, since I have never tried this.
You may be tempted to push the number of threads to some unholy number, but avoid the temptation. The overhead of creating and managing flows will soon catch up with you. I donβt know what the ideal number is, but you can experiment.
source share