Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Windows;
- namespace LVM
- {
- class MediaInfoThreaded
- {
- private static List<string> fileList;
- private static ManualResetEvent[] resetEvents;
- private static string[] wrkFolder;
- private static MediaInfo[] wrkMediaInfo;
- private static LvmDatabase db;
- public static void ParseFolderThreaded(string[] paths, int numThreads)
- {
- resetEvents = new ManualResetEvent[numThreads];
- wrkFolder = new string[numThreads];
- wrkMediaInfo = new MediaInfo[numThreads];
- db = new LvmDatabase();
- }
- for (int s = 0; s < numThreads; s++)
- {
- resetEvents[s] = new ManualResetEvent(false);
- wrkMediaInfo[s] = new MediaInfo();
- ThreadPool.QueueUserWorkItem(DoWork, (object)s);
- }
- //WaitHandle.WaitAll(resetEvents);
- }
- private static void DoWork(object o)
- {
- int index = (int)o;
- while (fileList.Count > 0)
- {
- lock(fileList)
- {
- wrkFolder[index] = fileList.FirstOrDefault();
- fileList.Remove(wrkFolder[index]);
- Console.WriteLine(wrkFolder[index]);
- }
- wrkMediaInfo[index].OpenTest(wrkFolder[index]);
- wrkMediaInfo[index].Close();
- }
- resetEvents[index].Set();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement