高手赐教B/S模式多线程例子,谢谢
legu1 2011-11-28 12:51:56 这是我的代码,但是感觉没有缩短时间,有没有办法让两个线程异步,该如何做
protected void Button3_Click(object sender, EventArgs e)
{
Thread thread2 = new Thread(new ThreadStart(bind2));
Thread thread1 = new Thread(new ThreadStart(bind1));
thread1.Start();
thread2.Start();
// thread.Join(TimeSpan.FromSeconds(100));
Thread.CurrentThread.Join(TimeSpan.FromSeconds(100));
thread2.Abort();
thread1.Abort();
}
protected void bind1()
{
string ids = this.txtID.Text.Trim(); //父类ID
string str = this.DropDownList2.SelectedValue.Trim();
if (str == "父级id值")
{
ids = this.txtID.Text.Trim();
}
else if (str == "class")
{
ids = "";
}
string xpath = this.txtXPath.Text.Trim();//抓取链接的xpath
string url = this.txtUrl.Text.Trim();//网站的url
string pagePath = "";
string s = getstr(url, ids, pagePath, xpath);//获取结果值
this.txtLianJie.Text += s;
}
protected void bind2()
{
string ids = this.txtID.Text.Trim(); //父类ID
string str = this.DropDownList2.SelectedValue.Trim();
if (str == "父级id值")
{
ids = this.txtID.Text.Trim();
}
else if (str == "class")
{
ids = "";
}
string xpath = this.txtXPath.Text.Trim();//抓取链接的xpath
string url = this.txtUrl.Text.Trim();//网站的url
string pagePath = "";
string s = getstr(url, ids, pagePath, xpath);//获取结果值
this.txtLianJie.Text += s;
}