using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace ThreadPoolExamples
{
    class Example5
    {
        private static void MyThreadEntryPoint(object arg)
        {
            string url = (string) arg;

            using (var w = new WebClient())
            {
                Console.WriteLine("Pobieranie strony " + url);
                string page = w.DownloadString(url);
                Console.WriteLine("Pobrano stronę {0}, długość {1}", url, page.Length);
            }
        }

        public static void StartNewTask()
        {
            // Listing 17-5
            Task.Factory.StartNew(MyThreadEntryPoint, "http://helion.pl/");
        }
    }
}
