日期:2014-05-17 浏览次数:20802 次
DirectoryInfo Di = new DirectoryInfo(LibPath);
DirectoryInfo[] directory = Di.GetDirectories();
int LibNo = directory.Length;
Task<DataTable>[] ts = new Task<DataTable>[LibNo];
for (int i = 0; i < LibNo; ++i)
{
ts[i] = Task.Factory.StartNew(() => Single_Lib(directory[i]));
}
Task.WaitAll(ts);
if (LibNo >= 5)
{
ts[0] = Task.Factory.StartNew(() => Single_Lib(directory[0]));
ts[1] = Task.Factory.StartNew(() => Single_Lib(directory[1]));
ts[2] = Task.Factory.StartNew(() => Single_Lib(directory[2]));
ts[3] = Task.Factory.StartNew(() => Single_Lib(directory[3]));
ts[4] = Task.Factory.StartNew(() => Single_Lib(directory[4]));
}
if (LibNo >= 6)
ts[5] = Task.Factory.StartNew(() => Single_Lib(directory[5]));
if (LibNo >= 7)
ts[6] = Task.Factory.StartNew(() => Single_Lib(directory[6]));