数据的读取-- >采集-- >入库 已经实现了,怎样通过多线程来提高效率呢?请大家指教
public void fenxi()
{
//在数据库获取一条记录
string fx = "select top 1 gjc from guanjianci where xiancheng=" + 0 + " order by id";
string gjc = sql.executeGetReturn(fx);//获取数据库中一个url地址,条件为xiancheng列=0
string url = "http://www.baidu.com/s?wd=";
using (SqlDataReader sdr = sql.getSdr(fx))
{
sdr.Read();
//获取相关网址的源代码
string code = pub.Body(url, gjc); //根据url获得源代码
code = code.Substring(1, 10); //截取前10个字符
// 将源代码入库
string update = "update guanjianci set neirong= '" + code + " ',xiancheng=" + 1 + " where gjc= '" + gjc + " '";
sql.getUpdate(update); //更新数据库的neirong列,并将xiancheng列更改为1
}
}
数据的读取-- >采集-- >入库 已经实现了,怎样通过多线程来提高效率呢?请大家指教
public void fenxi()
{
//在数据库获取一条记录
string fx = "select top 1 gjc from guanjianci where xiancheng=" + 0 + " order by id";
string gjc = sql.executeGetReturn(fx);//获取数据库中一个url地址,条件为xiancheng列=0
string url = "http://www.baidu.com/s?wd=";
using (SqlDataReader sdr = sql.getSdr(fx))
{
sdr.Read();
//获取相关网址的源代码
string code = pub.Body(url, gjc); //根据url获得源代码
code = code.Substring(1, 10); //截取前10个字符
// 将源代码入库
string update = "update guanjianci set neirong= '" + code + " ',xiancheng=" + 1 + " where gjc= '" + gjc + " '";
sql.getUpdate(update); //更新数据库的neirong列,并将xiancheng列更改为1
}
}
数据的读取-- >采集-- >入库 已经实现了,怎样通过多线程来提高效率呢?请大家指教
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货