日期:2014-05-17 浏览次数:20957 次
protected void search_Click(object sender, EventArgs e)
{
int Start = 0;
string question = TextBox1.Text.ToString();
if (question.Equals(""))
{
Response.Write("请输入您要查询的内容!");
}
else
{
Response.Write("正在查询并下载网页...");
Thread[] myThread;//声名下载线程
int n = 1;//设置线程总数,同时规定下载的连接数 此处为1000,即下载1000个链接
myThread = new Thread[ n ];//为线程申请资源,确定线程总数
for( int i = 0; i < n; i++ )
{
Start = i * 10;
string gurl = "http://www.google.com/search?q=" + System.Web.HttpUtility.UrlEncode(question) + "&start=" + Start;//按照UTF8编码
imple myimpl = new imple(gurl, question,Start);
ThreadStart startDownload = new ThreadStart(myimpl.getgoogle);
myThread[i] = new Thread( startDownload );//指定线程起始设置
myThread[i].Start();//逐个开启线程
//判断线程是不是结束~
int time = new Random().Next(1000);//休眠1000毫秒内的随机数
Thread.Sleep(time);
}
//while (IsAlive)???该怎么写呢?
//{ }
}
}
int num = 0, num1 = 0, num2 = 0, num3 = 0;
&nbs