多任务检查代理

我写了那个小程序:
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();

            }
我希望它同时检查几个代理...不是一个接一个:) 有人可以帮忙吗?     
已邀请:
好吧,你可以使用.AsParallel扩展方法。 更改
foreach(var ip in listBox1.Items)
foreach(var ip in listBox1.Items.AsParallel())
    

要回复问题请先登录注册