private void button8_Click(object sender, EventArgs e) { ts2 = new CancellationTokenSource(); ct2 = ts2.Token; ct_p = ts_p.Token; tabControl1.SelectedTab = tabControl1.TabPages[1]; this.Refresh(); ReferenceSystem.Default def = (ReferenceSystem.Default)listBox1.SelectedItem; відмінитиПоточнуОпераціюToolStripMenuItem.Enabled = true; var task = Task.Factory.StartNew(() => { addText("Обчислення розпочато...\r\n"); string file = SphericalHarmonicAnalyze.Properties.Settings.Default.inGravityModel; GravityModel gm = new GravityModel(SphericalHarmonicAnalyze.Properties.Settings.Default.modelMaxOrder); gm.loadFromFile(SphericalHarmonicAnalyze.Properties.Settings.Default.inGravityModel, new setProgressDel(addVal)); ReferenceSystem elipsoid = new ReferenceSystem(def); elipsoid.gridParameters.cellSize = SphericalHarmonicAnalyze.Properties.Settings.Default.GridCellSize; elipsoid.gridParameters.coLatitudeBounds = SphericalHarmonicAnalyze.Properties.Settings.Default.minCoLatitude; elipsoid.maxDegree = SphericalHarmonicAnalyze.Properties.Settings.Default.modelMaxOrder; int greedColumnsCount, greedRowsCount; List <double[]> greed = MathFunc.generateGrid(elipsoid.gridParameters.cellSize, out greedColumnsCount, out greedRowsCount, SphericalHarmonicAnalyze.Properties.Settings.Default.minCoLatitude, SphericalHarmonicAnalyze.Properties.Settings.Default.maxCoLatitude, SphericalHarmonicAnalyze.Properties.Settings.Default.longW, SphericalHarmonicAnalyze.Properties.Settings.Default.longE); addText("Колонок: {0}\r\n", greed.Count); double[][] h_dg = GravityModel.getGeoidHeightAndAnomalys(elipsoid, gm, greed, d: new setProgressDel(addVal), ct: ct2, ct2: ct_p); if (ct2.IsCancellationRequested) { addText("Перервано...\r\n"); addVal(0, 1, ""); Thread.CurrentThread.Abort(); } ; addText("dg обчислено\r\n"); IOFunc.writeGeoidHeightsAndAnomalysToTxt(greed, h_dg[0], h_dg[1], elipsoid, file + "B_L_N_dg.txt"); addText("Готово...\r\nРезультати записано в файл: " + file + "NEW____________B_L_N_dg.txt\r\n"); }, ct2); var t3 = Task.Factory.StartNew(() => { label1: if (task.IsCompleted) { if (checkBox1.Checked) { System.Diagnostics.Process.Start("rundll32.exe", "powrprof.dll,SetSuspendState 0,1,0"); } ; } else { task.Wait(); goto label1; } }); }