private void DoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            var start = DateTime.Now;

            var options = (UserOptions)doWorkEventArgs.Argument;

            var generator = new GalleryGeneratorEngine.DirectoryProcessors.GalleryGeneratorEngine(options, () => this.worker.CancellationPending, () => { doWorkEventArgs.Cancel = true; });

            var  senderWorker = (BackgroundWorker)sender;
            long counter      = 0;

            generator.ProcessingFileEvent += file =>
            {
                var p = (double)counter / (double)options.WorkSize;
                senderWorker.ReportProgress((int)(p * 100), file);
                counter++;
            };

            var result = generator.StartTask();

            var end = DateTime.Now;

            result.TimeSpan = end - start;

            doWorkEventArgs.Result = result;
        }
        private void DoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            var start = DateTime.Now;

            var options = (UserOptions)doWorkEventArgs.Argument;

            var generator = new GalleryGeneratorEngine.DirectoryProcessors.GalleryGeneratorEngine(options, () => this.worker.CancellationPending, () => { doWorkEventArgs.Cancel = true; });

            var senderWorker = (BackgroundWorker) sender;
            long counter = 0;
            generator.ProcessingFileEvent += file =>
            {
                var p = (double)counter/(double)options.WorkSize;
                senderWorker.ReportProgress((int)(p*100), file);
                counter++;
            };

            var result = generator.StartTask();

            var end = DateTime.Now;
            result.TimeSpan = end - start;

            doWorkEventArgs.Result = result;
        }