private async Task BSA_Method() { await Task.Factory.StartNew(() => { Random random = new Random(DateTime.Now.Millisecond); ExtendedPoint point = new ExtendedPoint(); point.X = random.Next(-10, 10); point.Y = random.Next(-10, 10); best.QuantityVectrors = 10; var result = best.StartSolution(point); string Res = string.Format("Результат: {0}\nX: {1}\nY: {2}", result.ToString(), best.EndPoint.X, best.EndPoint.Y); BSA_Result.Invoke(new Action(() => BSA_Result.Text = Res)); BSA_Result.Invoke(new Action(() => BSA_ProgressBar.Value = 0)); progressValueStart = 2; }); }
private void button1_Click(object sender, EventArgs e) { Random random = new Random(DateTime.Now.Millisecond); string function = FunctionTextBox.Text; double testStep = double.Parse(TestStepInputTextBox.Text.Replace(".", ",")); ExtendedPoint point = new ExtendedPoint(); point.X = random.Next(-10, 10); point.Y = random.Next(-10, 10); best = new BestSampleAlgorithm(function, testStep); best.QuantityVectrors = int.Parse(VectorsInputTextBox.Text); var result = best.StartSolution(point); OutPutXLabel.Text = best.EndPoint.X.ToString(); OutPutYLabel.Text = best.EndPoint.Y.ToString(); XinputLabel.Text = point.X.ToString(); YinputLabel.Text = point.Y.ToString(); ResultOutputLable.Text = result.ToString(); }