Beispiel #1
0
        static void SingleThreadSupport(FileInfo[] files)
        {
            MyXmlReader reader = new MyXmlReader();
            LuaFile     lua    = new LuaFile();

            foreach (FileInfo item in files)
            {
                ElementData root = reader.ReadXmlFile(item.FullName);
                lua.FileGeneration(item.FullName, root);
            }
        }
Beispiel #2
0
        static void MultiThreadSupport(FileInfo[] files)
        {
            List <Task> taskList = new List <Task>();

            foreach (FileInfo item in files)
            {
                Task newTask = Task.Run(() =>
                {
                    MyXmlReader reader = new MyXmlReader();
                    LuaFile lua        = new LuaFile();
                    ElementData root   = reader.ReadXmlFile(item.FullName);
                    lua.FileGeneration(item.FullName, root);
                });
                taskList.Add(newTask);
            }
            if (taskList.Count > 0)
            {
                Task.WaitAll(taskList.ToArray());
            }
        }