- I have a method that uses a connection (e.g. a method that downloads a page).
- I have to execute this method multiple times (e.g. download 1000 pages).
- Doing it the synchronous and sequential way takes a long time.
- I have limited resources ( 8 max threads and/or 50 max simultaneous connections )
- I want to use all resources to accelerate it.
- I know that parallelization (PLINQ, Parallel Extensions, etc.) could solve the problem, but I have already tried it, and this approach fails because of the scarce resources.
- I don't want to reinvent the wheel that parallelizes this kind of task while managing the resources, someone must have done it before and must have provided a library/tutorial for this.
Can anyone help?
Update Things get much more complicated when you start to mix Asynchronous calls with Parallelization for maximum performance. This is implemented on several downloaders, like Firefox downloader, it gets 2 downloads simultaneously and when one of them is complete it gets the next file and so on. Maybe it seems very simple to implement, but when I implemented it I had, and still have, trouble to make it generic (useful for WebRequest and DbCommand) and to deal with problems (ie. timeouts)
Bounty Hunters The bounty will be granted to the first one that links a reliable and free($$) .NET library that provides a simple C# way to parallelize async tasks as HttpWebRequests.BegingetResponse and SqlCommand.BeginExecuteNonQuery. The parallelization must not wait for N tasks to complete to then start the next N, but it must start a new task as soon as one of the N initial ones finishes. The method must was provide timeout handling.