I'm still getting the handle of .NET 4 multithreading libraries so I'm not sure if they're more helpful here than a lower level solution.
I have a BlockingCollection of messages which need to be send to some HTTP service endpoint. Normally my solution would be to create an infinite looping function like so
void DoWork()
{
while(true)
{
var message = collection.Take();
SendMessage();
}
}
start X number of Thread() objects to work the loop. The multiple threads account for the time spent waiting for HTTP responses then I'd profile and tune the performance to figure out the correct number of threads to use.
Is this a better fit for tasks?