62,272
社区成员
发帖
与我相关
我的任务
分享 var StartTime = DateTime.Now;
IList<abc> listProduct = bll.GetAllInfoByGIA();
int succNum;
var count = listProduct.Count / 5;
var num1 = 0;
System.Threading.Thread thread1 = new System.Threading.Thread(delegate()
{
//执行抓取方法;
for (int i = 0; i < count; i++)
{
num1 += GatherGIA(listProduct[i]);
}
});
thread1.Start();
var num2 = 0;
System.Threading.Thread thread2 = new System.Threading.Thread(delegate()
{
//执行抓取方法;
for (int i = count; i < 2 * count; i++)
{
num2 += GatherGIA(listProduct[i]);
}
});
thread2.Start();
var num3 = 0;
System.Threading.Thread thread3 = new System.Threading.Thread(delegate()
{
//执行抓取方法;
for (int i = 2 * count; i < 3 * count; i++)
{
num3 += GatherGIA(listProduct[i]);
}
});
thread3.Start();
var num4 = 0;
System.Threading.Thread thread4 = new System.Threading.Thread(delegate()
{
//执行抓取方法;
for (int i = 3 * count; i < 4 * count; i++)
{
num4 += GatherGIA(listProduct[i]);
}
});
thread4.Start();
var num5 = 0;
System.Threading.Thread thread5 = new System.Threading.Thread(delegate()
{
//执行抓取方法;
for (int i = 4 * count; i < listProduct.Count; i++)
{
num5 += GatherGIA(listProduct[i]);
}
});
thread5.Start();
while (true)
{
if (thread1.ThreadState != System.Threading.ThreadState.Stopped) continue;
if (thread2.ThreadState != System.Threading.ThreadState.Stopped) continue;
if (thread3.ThreadState != System.Threading.ThreadState.Stopped) continue;
if (thread4.ThreadState != System.Threading.ThreadState.Stopped) continue;
if (thread5.ThreadState != System.Threading.ThreadState.Stopped) continue;
break;
}
thread1.Abort();
thread2.Abort();
thread3.Abort();
thread4.Abort();
thread5.Abort();
