StreamReader sr = new StreamReader("data.txt");
private void run_Click(object sender, EventArgs e)
{
url = Uurl.Text.ToString();
num = 0;
if(url.Contains(@"http://"))
{
url=url.Replace(@"http://","");
}
myThread = new Thread(new ThreadStart(runSEO));
this.run.Enabled = false;
myThread.Start();
}
public void runSEO()
{
try
{
while ((urlhead = sr.ReadLine()) != null)
{
num = num + 1;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlhead + url);
request.Timeout = 1000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
sr.Close();
run.Invoke(btnchange);
}
catch
{
run.Invoke(btnchange);
}
}
如果请求的网址超时,为什么我的线程是直接停止而不是跳过这个网址继续request下一个呢?怎样让它在请求一个网址不成功就跳过继续下一个?