using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
namespace ParallelRSS
{
class Program
{
private static string ProcessRSS(string feedUrl)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(feedUrl);
var response = request.GetResponse();
return (new StreamReader(response.GetResponseStream())).ReadToEnd();
}
private static string[] GetURLs()
{
return new string[] {
"http://habrahabr.ru/rss/",
"http://quux.uz/rss/",
"http://www.cbr.ru/scripts/RssPress.asp"
};
}
static void Main(string[] args)
{
try
{
var data = GetURLs().AsParallel().Select(url => ProcessRSS(url));
foreach (string x in data)
{
Console.WriteLine(x);
}
}
catch (AggregateException e)
{
}
Console.Read();
}
}
}