void Finished(DataTable table, Exception e) { BeginInvoke((Action) delegate { Result = table; progressBar.Value = (int)(calculation.Progress() * 100); progressTimer.Stop(); progressTimer.Tick -= ProgressTimer_Tick; calculation = null; UpdateUI(); }); }
void StartCalculation() { cancellation = new CancellationTokenSource(); calculation = new ParallelCalculation { Prof = this.Prof, Prop = this.Prop, Rango = this.Rango }; calculation.Run(Finished, cancellation.Token, threads); progressBar.Value = 0; progressTimer = new System.Windows.Forms.Timer(components) { Interval = 100 }; progressTimer.Tick += ProgressTimer_Tick; progressTimer.Start(); UpdateUI(); }