using System using System IO using System Linq using System Net using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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();
}
}
}