Ejemplo n.º 1
0
        public void Run()
        {
            _logger.LogDebug("Application is started.");

            try
            {
                var pathToFolder = GetPathToFolder();
                var searchMask   = "*.mp3";

                var mp3Files = Directory.GetFiles(pathToFolder, searchMask, SearchOption.AllDirectories);

                var foreachStrategy = new ForeachStrategy(_renameFileService);
                _timerService.MeasureExecutionTime(foreachStrategy.RenameFiles, mp3Files);

                var parallelForeachStrategy = new ParallelForeachStrategy(_renameFileService);
                _timerService.MeasureExecutionTime(parallelForeachStrategy.RenameFiles, mp3Files);

                var tasksStrategy = new TasksStrategy(_renameFileService);
                _timerService.MeasureExecutionTime(tasksStrategy.RenameFiles, mp3Files);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
            }
            finally
            {
                _logger.LogDebug("Application is stopped.");
            }
        }