Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Net;
- using System.Net.Http;
- using System.Threading.Tasks;
- class Program
- {
- static void Main()
- {
- int[] subforums = {
- 6, 15, 16, 36, 38, 40, 46, 51, 56, 60, 62, 64, 65, 66, 75, 76, 107,
- 110, 189, 198, 240, 243, 262, 277, 315, 316, 339, 353, 361, 383,
- 384, 385, 389, 391, 393, 394, 396, 397, 401, 403, 408, 409, 411,
- 412, 414, 415 };
- ServicePointManager.DefaultConnectionLimit = 100;
- var client = new HttpClient();
- var tasks = new Task<string>[subforums.Length];
- var time = new Stopwatch();
- time.Start();
- Parallel.For(0, subforums.Length, subforum =>
- tasks[subforum] = client.GetStringAsync(
- "http://www.facepunch.com/forumdisplay.php?f=" +
- subforums[subforum]));
- Task.WaitAll(tasks);
- time.Stop();
- Console.WriteLine("Request completed in {0} seconds.",
- ((float)time.ElapsedMilliseconds / 1000).ToString("F3"));
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment