private void _DoAnalysisBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { MethodEvaluators methodEvaluators = (MethodEvaluators)e.Argument; ExecuteOnOwningThread(analysisProgressLabel, () => { analysisProgressBar.Visible = true; analysisProgressLabel.Visible = true; analysisProgressBar.Value = 0; analysisProgressLabel.Text = "0 %"; }); MethodEvaluation cashEval = methodEvaluators.SavingCashEvaluation; MoneyBalanceOverTime cashResult = cashEval.StartEvaluation(SetProgress, 0, 33); MethodEvaluation standardEval = methodEvaluators.StandardEvaluation; MoneyBalanceOverTime standardResult = standardEval.StartEvaluation(SetProgress, 34, 66); MethodEvaluation experimentalEvaluation = methodEvaluators.ExperimentalEvaluation; MoneyBalanceOverTime experimentalResult = experimentalEvaluation.StartEvaluation(SetProgress, 67, 100); var results = new EvaluatorsResults(cashResult, standardResult, experimentalResult); e.Result = results; }
private void _GetDataBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { StockMarketHistoricalData data = e.Result as StockMarketHistoricalData; if (data != null) { HistoricalData = data; } //now that we have the data - do the analysis MethodEvaluation cashEvaluation = new MethodEvaluation(new NoActionStrategy(SelectedSchedule, this.StartDateTimePicker.Value, this.EndDateTimePicker.Value), HistoricalData); MethodEvaluation standardEvaluation = new MethodEvaluation(new AlwaysBuyStrategy(SelectedSchedule, this.StartDateTimePicker.Value, this.EndDateTimePicker.Value), HistoricalData); MethodEvaluation experiment = new MethodEvaluation(SelectedStrategy, HistoricalData); var evaluators = new MethodEvaluators(cashEvaluation, standardEvaluation, experiment); _DoAnalysisBackgroundWorker.RunWorkerAsync(evaluators); }