public DataFlowBuilder BuildConsumers() { for (int i = 0; i < _consumerThreadsCount; i++) { var consumer = DataFlowFactory.CreateConsumer(_executionContext, _arguments.DataFlow); var workThread = new WorkThread(consumer.StartConsuming); workThread.CommandException += (sender, args) => { _logger.Fatal(((DataProcessingExceptionEventArgs)args).Exception); Console.WriteLine("\r\nAn exception occured while processing data. Check logs for details"); _executionContext.StopExecution(); }; _threads.Add(workThread); } return(this); }
public DataFlowBuilder BuildProducer() { var producer = DataFlowFactory.CreateProducer(_executionContext, _arguments.DataFlow); var workThread = new WorkThread(producer.StartProducing); workThread.CommandException += (sender, args) => { _logger.Fatal(((DataProcessingExceptionEventArgs)args).Exception); Console.WriteLine("\r\nAn exception occured while reading data. Check logs for details"); _executionContext.StopExecution(); }; producer.ProgressChanged += (sender, e) => { Console.Write("\rCompleted " + ((ProgressChangedEventArgs)e).PercentageCompleted + "%"); }; _threads.Add(workThread); return(this); }