FeedJournal, like any RSS aggregator, needs to be efficient when it is updating the list of subscribed feeds. It is obvious that a sequential polling of feeds (check each feed and proceed to the next after finishing with the previous) will be sub-optimal in terms of performance and user experience. The internet requests will need to occur in parallel for optimal performance. However, if your feed subscription list contains more than a trivial amount of feeds, you don't want to congest your Internet line with all of these request at the same time.
IE7's RSS infrastructure calls this throttling, and it limits the number of concurrent web requests to 4. I don't see a reason to differ from this approach and implemented the same system.
One of the great things about .NET 2.0 is the easy-to-use infrastructure for multithreading and thread synchronization
In FeedJournal's case the scenario becomes a little bit more complicated since if I let the method that iterates the feed updates run in the same thread as the GUI, it will become unresponsive. Therefore the main thread calls RunWorkerAsync(
Throttling the maximum number of concurrent downloads is then simply achieved by the line:
ThreadPool.SetMaxThreads(4, 1000);
telling the ThreadPool to have a maximum of 4 actively executing threads at any given time.
Comments
Post a Comment