public void run(Action<List<string>> onload)
{
List<string> directoryLists = new List<string>();
directoryLists = Directory.GetDirectories(m_importPath).ToList();
Parallel.ForEach(directoryLists,new ParallelOptions { MaxDegreeOfParallelism=10}, i =>
{
List<string> files = importer(i);
onload(files);
}
}
Action<List<string>> onload = dir =>
{
BeginInvoke(new EventHandler((obj, even) =>
{
var root = new TreeNode(dir[0]);
for (int i = 1; i < dir.Count; i++)
{
string fileName = dir[i].Substring(dir[i].LastIndexOf('\\') + 1);
root.Nodes.Add(fileName.Remove(fileName.IndexOf('.')));
}
this.treeView1.Nodes.Add(root);
}), null);
};
import.run(onload);