Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 多任务检查代理_C#_.net 3.5_Proxies_Anonymity - Fatal编程技术网

C# 多任务检查代理

C# 多任务检查代理,c#,.net-3.5,proxies,anonymity,C#,.net 3.5,Proxies,Anonymity,我写了一个小程序: 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 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();

            }
我希望它同时检查几个代理。。。不是一个接一个:) 有人能帮忙吗?

好吧,你可以用这个

改变

foreach(var ip in listBox1.Items)


如果我使用的是.NET3.5,还有其他方法吗?你可以使用Framework3.5的并行扩展,但这需要更多的代码,请参阅下载
foreach(var ip in listBox1.Items.AsParallel())