0

I wrote that little program:

string sciezka = "http://proxyjudge.hell-spy.de/";

        foreach(var ip in listBox1.Items)
        {
            ////////////////// CHANGES IP:PORT TO WEBPROXY HOST,PORT
            string host=null;
            string zmiana=null;
            string sport = null;
            int port=0;
            int pozycja=0;
            zmiana=ip.ToString();
            pozycja=zmiana.IndexOf(":");
            host=zmiana.Remove(pozycja);
            sport = zmiana.Replace(host + ":", "");
            port = int.Parse(sport);
            ////////////////////////////////////////// CONNECTING TO PROXYJUDGE
            string anonymous=null;
            try
            {
                WebRequest request = WebRequest.Create(sciezka);
                WebProxy myprox = new WebProxy(host, port);
                request.Timeout = 5000;
                request.Proxy = myprox;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream strumien = response.GetResponseStream();
                StreamReader sr = new StreamReader(strumien);
                anonymous = sr.ReadToEnd();
                if (anonymous.Contains("HTTP_VIA"))
                {
                    listBox3.Items.Add(zmiana);
                }
                else
                {
                    listBox2.Items.Add(zmiana);
                }
                Update();
                request.Abort();

                sr.Close();
            }
            catch (Exception ex)
            {
                listBox3.Items.Add(zmiana);
                Update();

            }

and I want that it check few proxies at the same time... not one by one :) can someone help with that?

4

1 回答 1

0

好吧,您可以使用.AsParallel 扩展方法

改变

foreach(var ip in listBox1.Items)

foreach(var ip in listBox1.Items.AsParallel())
于 2010-09-24T11:43:46.767 回答