public void RunProcessManager(CompressionParams settings) { using (var reader = new FileStream(settings.SourceFile, FileMode.Open, FileAccess.Read, FileShare.Read, settings.BlockSize, FileOptions.Asynchronous)) { using (var writer = new FileStream(settings.RecoverFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, settings.BlockSize, FileOptions.Asynchronous)) { var readerWriter = readerWriterFactory.GetFileReaderWriter(reader, writer); pool.StartThreadPool(); settings.Mode.Instruction.Processing(pool, readerWriter); long res = 0, old = 0; while (!pool.IsFinished()) { Thread.Sleep(100); if (!pool.QueueExceptionIsEmpty()) { throw pool.GetThreadsException(); } if (old < (res = (100 * reader.Position) / reader.Length)) { Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " Прогресс: " + (old = res) + "%"); } } settings.Mode.Instruction.PostProcessing(readerWriter); pool.Stop(); } } }