public void DoWork() { try { recursiveFileProcessor = new RecursiveFileProcessor(_shutdownEvent, _pauseEvent); Console.Title = Path.GetFileName(_path) + " Enqueue-Producer"; if (Directory.Exists(_path)) { //Debug Lines below: 2 Lines below. Console.WriteLine(_path); Console.WriteLine(Directory.Exists(_path)); // This path is a directory recursiveFileProcessor.ProcessDirectory(_path); Console.WriteLine("The thread has completed its work. Press ENTER to continue."); } else { Console.WriteLine("{0} is not a valid directory.", _path); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.TargetSite); } finally { if (recursiveFileProcessor != null) { recursiveFileProcessor = null; } } }
public void Stop() { float processedFilesValueInFloat = 0.0F; RedisValue processedFilesSizeValue = keyValueCache.StringGet("Enqueue-Producer"); if (processedFilesSizeValue.HasValue) { processedFilesValueInFloat = Convert.ToSingle(processedFilesSizeValue); } else { processedFilesValueInFloat = 0.0F; } Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("The % data migrated is {0} %", ((processedFilesValueInFloat / (1024 * 1024)) / (RecursiveFileProcessor.CalculateFolderSize(_path, _shutdownEvent, _pauseEvent) / (1024 * 1024))) * 100); Console.WriteLine("Application, now stopping."); Console.ResetColor(); // Signal the shutdown event _shutdownEvent.Set(); // Make sure to resume any paused threads _pauseEvent.Set(); // Wait for the thread to exit _thread.Join(); }
public void Pause() { float processedFilesValueInFloat = 0.0F; RedisValue processedFilesSizeValue = keyValueCache.StringGet("Enqueue-Producer"); if (processedFilesSizeValue.HasValue) { processedFilesValueInFloat = Convert.ToSingle(processedFilesSizeValue); } else { processedFilesValueInFloat = 0.0F; } Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("The % data migrated is {0} %", ((processedFilesValueInFloat / (1024 * 1024)) / (RecursiveFileProcessor.CalculateFolderSize(_path, _shutdownEvent, _pauseEvent) / (1024 * 1024))) * 100); Console.WriteLine("Application, now paused."); Console.ResetColor(); _pauseEvent.Reset(); }