public TablesDump Perform() { PrepareTables(); foreach (var calc in MainCalcUnits.LoadAllCalcs()) { calc.Initialize(tables, userInput, calcMemory); try { calc.Perform(); } catch (CalcDebugInterruptException e) { Console.WriteLine(e); MessageBox.Show("Interrupted: " + e.Message); break; } } return(tables.GetAllOutputDataTables()); }
public void Perform(BackgroundWorker worker, DoWorkEventArgs e) { PrepareTables(); var resultHolder = (Holder <object>)e.Argument; var calcs = MainCalcUnits.LoadAllCalcs(); var calcPerc = 100d / calcs.Count; var totalPerc = 0d; foreach (var calc in calcs) { if (worker.CancellationPending) { e.Cancel = true; break; } calc.Initialize(tables, userInput, calcMemory); try { calc.Perform(); } catch (Exception exc) { Console.WriteLine(exc); MessageBox.Show($"Обчислення були перервані через помилку: \n\n{exc.Message}", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } totalPerc += calcPerc; worker.ReportProgress(Convert.ToInt32(totalPerc)); } resultHolder.Value = tables.GetAllOutputDataTables(); }