private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            var worker = sender as BackgroundWorker;

            //TODO: reset compiled data;

            long fileCounter = 0;
            StartDateTime = DateTime.Now;
            CollectionDateTime = null;
            CompressionTestDateTime = null;

            foreach (var file in SafeFileEnumerator.EnumerateFiles(txt_BasePath.Text, "*.*", SearchOption.AllDirectories))
            {
                Data.AddFile(file);
                fileCounter++;

                if (fileCounter % 5000 == 0)
                {
                    worker.ReportProgress(0);

                    if (worker.CancellationPending == true)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }

            //force refresh
            worker.ReportProgress(0);

            CollectionDateTime = DateTime.Now;
            fileCounter = 0;
            Random rnd = new Random();
            int minFileCountToTest = int.Parse(txt_MinFileCount.Text);

            using (var compressionTester = new FileCompressionTester(int.Parse(txt_MaxTestBytes.Text)))
            {
                foreach (var extensionPilePair in Data)
                {
                    if (!extensionPilePair.KnownCompressed || chk_TestKnownTypes.Checked)
                    {
                        int fileCountToTest = minFileCountToTest;
                        if (extensionPilePair.Files.Files.Count / 10 > fileCountToTest)
                            fileCountToTest = extensionPilePair.Files.Files.Count / 10;

                        foreach (var file in extensionPilePair.Files.Files.Shuffle(rnd).Take(fileCountToTest))
                        {
                            fileCounter++;
                            int thisTestByteLength = 0;
                            int thisTestOutputLength = 0;

                            if (compressionTester.TestCompressionRatio(file.FullName, out thisTestByteLength, out thisTestOutputLength) != null)
                                Data.AddCompressionStat(file, thisTestByteLength, thisTestOutputLength);
                            else
                                //TODO: think about how to pass error message around
                                Data.AddErrorEntry(file, "Unknown");

                            if (fileCounter % 10 == 0)
                            {
                                worker.ReportProgress(0);

                                if (worker.CancellationPending == true)
                                {
                                    e.Cancel = true;
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            CompressionTestDateTime = DateTime.Now;
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            var worker = sender as BackgroundWorker;

            //TODO: reset compiled data;

            long fileCounter = 0;

            StartDateTime           = DateTime.Now;
            CollectionDateTime      = null;
            CompressionTestDateTime = null;

            foreach (var file in SafeFileEnumerator.EnumerateFiles(txt_BasePath.Text, "*.*", SearchOption.AllDirectories))
            {
                Data.AddFile(file);
                fileCounter++;

                if (fileCounter % 5000 == 0)
                {
                    worker.ReportProgress(0);

                    if (worker.CancellationPending == true)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }

            //force refresh
            worker.ReportProgress(0);

            CollectionDateTime = DateTime.Now;
            fileCounter        = 0;
            Random rnd = new Random();
            int    minFileCountToTest = int.Parse(txt_MinFileCount.Text);

            using (var compressionTester = new FileCompressionTester(int.Parse(txt_MaxTestBytes.Text)))
            {
                foreach (var extensionPilePair in Data)
                {
                    if (!extensionPilePair.KnownCompressed || chk_TestKnownTypes.Checked)
                    {
                        int fileCountToTest = minFileCountToTest;
                        if (extensionPilePair.Files.Files.Count / 10 > fileCountToTest)
                        {
                            fileCountToTest = extensionPilePair.Files.Files.Count / 10;
                        }

                        foreach (var file in extensionPilePair.Files.Files.Shuffle(rnd).Take(fileCountToTest))
                        {
                            fileCounter++;
                            int thisTestByteLength   = 0;
                            int thisTestOutputLength = 0;

                            if (compressionTester.TestCompressionRatio(file.FullName, out thisTestByteLength, out thisTestOutputLength) != null)
                            {
                                Data.AddCompressionStat(file, thisTestByteLength, thisTestOutputLength);
                            }
                            else
                            {
                                //TODO: think about how to pass error message around
                                Data.AddErrorEntry(file, "Unknown");
                            }

                            if (fileCounter % 10 == 0)
                            {
                                worker.ReportProgress(0);

                                if (worker.CancellationPending == true)
                                {
                                    e.Cancel = true;
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            CompressionTestDateTime = DateTime.Now;
        }