Ejemplo n.º 1
0
        public bool Start(FileReader fileReader, Archiever archiever, FileWriter fileWriter, OperationType operationType)
        {
            ConsoleLogger.WriteDiagnosticInfo($"{operationType.DisplayName()} of {_sourceFilePath} to {_targetFilePath} is started...");

            new Thread(fileReader.Read).Start();

            for (int i = 0; i < coresCount; i++)
            {
                var current = i;
                new Thread(() => archiever.Start(current)).Start();
            }

            var threadToWrite = new Thread(fileWriter.Save);

            threadToWrite.Start();

            threadToWrite.Join();
            if (StatusManager.Exception != null)
            {
                ConsoleLogger.WriteError(StatusManager.Exception.Message);
                return(false);
            }

            return(true);
        }