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())