public static ParsePerformanceData Parse(string directory, RootPackage rootPackage)
        {
            var ppd = new ParsePerformanceData {
                BaseDirectory = directory
            };

            /*
             * 1) List all files
             * 2) Create module packages
             * 3) Enlist all file-package pairs in the queue
             * 4) Start parse threads
             * 5) Wait for all to join
             */

            var tpd = new ThreadedDirectoryParser
            {
                baseDirectory = directory
            };

            // 1), 2), 3)
            tpd.PrepareQueue(rootPackage);

            ppd.AmountFiles = tpd.queue.Count;
            var sw = new Stopwatch();

            sw.Start();

            // 4)
            var threads = new Thread[numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var th = threads[i] = new Thread(tpd.ParseThread)
                {
                    IsBackground = true,
                    Priority     = ThreadPriority.Lowest,
                    Name         = "Parser thread #" + i + " (" + directory + ")"
                };
                th.Start();
            }

            // 5)
            for (int i = 0; i < numThreads; i++)
            {
                if (threads[i].IsAlive)
                {
                    threads[i].Join(10000);
                }
            }

            sw.Stop();
            ppd.TotalDuration = sw.Elapsed.TotalSeconds;

            return(ppd);
        }
        public static ParsePerformanceData Parse(string directory, RootPackage rootPackage)
        {
            var ppd = new ParsePerformanceData { BaseDirectory = directory };

            /*
             * 1) List all files
             * 2) Create module packages
             * 3) Enlist all file-package pairs in the queue
             * 4) Start parse threads
             * 5) Wait for all to join
             */

            var tpd = new ThreadedDirectoryParser
            {
                baseDirectory = directory
            };

            // 1), 2), 3)
            tpd.PrepareQueue(rootPackage);

            ppd.AmountFiles = tpd.queue.Count;
            var sw = new Stopwatch();
            sw.Start();

            // 4)
            var threads = new Thread[numThreads];
            for (int i = 0; i < numThreads; i++)
            {
                var th = threads[i] = new Thread(tpd.ParseThread) {
                    IsBackground = true,
                    Priority= ThreadPriority.Lowest,
                    Name = "Parser thread #"+i+" ("+directory+")"
                };
                th.Start();
            }

            // 5)
            for (int i = 0; i < numThreads; i++)
                if (threads[i].IsAlive)
                    threads[i].Join(10000);

            sw.Stop();
            ppd.TotalDuration = sw.Elapsed.TotalSeconds;

            return ppd;
        }