请各位帮忙看看这个关于线程的问题
我在主框架中启动一个线程去执行(调用web serices):foreach (string f in fn)
{
string t = null;
System.IO.StreamReader fi = System.IO.File.OpenText(f);
while (fi.Peek() >= 0)
{
string zh = null;
string non = null;
string ip = null;
string qh = null;
string sxt = null;
string xxt = null;
string v = null;
t = null;
t += fi.ReadLine().Trim();
zh += t.Substring(0, t.IndexOf(","));
string tt1 = t.Substring(t.IndexOf(",") + 1, t.Length - t.IndexOf(",") - 1);
non = tt1.Substring(0, tt1.IndexOf(","));
tt1 = tt1.Substring(tt1.IndexOf(",") + 1, tt1.Length - tt1.IndexOf(",") - 1);
ip = tt1.Substring(0, tt1.IndexOf(","));
tt1 = tt1.Substring(tt1.IndexOf(",") + 1, tt1.Length - tt1.IndexOf(",") - 1);
qh = tt1.Substring(0, tt1.IndexOf(","));
tt1 = tt1.Substring(tt1.IndexOf(",") + 1, tt1.Length - tt1.IndexOf(",") - 1);
sxt = tt1.Substring(0, tt1.IndexOf(","));
tt1 = tt1.Substring(tt1.IndexOf(",") + 1, tt1.Length - tt1.IndexOf(",") - 1);
xxt = tt1.Substring(0, tt1.IndexOf(","));
tt1 = tt1.Substring(tt1.IndexOf(",") + 1, tt1.Length - tt1.IndexOf(",") - 1);
v = tt1.Substring(0, tt1.Length);
sqlstr = null;
sqlstr += "insert into DiaoXian(zhanghao,non,ip,quhao,shangxian_time,xiaxian_time,v,from_file) values(";
sqlstr += "'" + zh + "',";
sqlstr += "'" + non + "',";
sqlstr += "'" + ip + "',";
sqlstr += "'" + qh + "',";
sqlstr += "'" + sxt + "',";
sqlstr += "'" + xxt + "',";
sqlstr += "'" + v + "',";
sqlstr += "'" + f + "')";
using (noczb.Service1 ss = new noczb.Service1())
{
string er = null;
do
{
try
{
er = null;
ss.RunInAddUpSql(sqlstr);//调用web serices
}
catch (System.Exception e)
{
er = e.Message.ToString();
wlog1(@"err1.txt", "trun_new::" + er + "," + sqlstr + "," + System.DateTime.Now.ToString());//写报错文件
}
} while (er != null && er != "");
ss.Dispose();
}
tot_n++;
jm1.txtnum = tot_n;
}
fi.Close();
}
执行一段时间后(不定时),线程会自动退出(没有报任何错误),线程返回值为0。
我把这段代码放在主框架下执行没有发生任何问题,就是只要用线程执行就会自动退出,请各位大虾帮我看看会是什么问题???????
谢谢啊,我已经搞了一个多月了怎么都不行。
我是新手还没有分数,请大家帮帮忙 --------------------编程问答-------------------- 自己顶一下
新手没分给,就没人理了
惨!!!!!
补充:.NET技术 , C#