private void DoProcess() { try { CloudParaFileStatics st = new CloudParaFileStatics(); string[] result = st.FilesSVDStat(_lfiles, _leftBandNum, _fillvalueL, _rfiles, _rightBandNum, _fillvalueR, _leftRatio, _rightRatio, _outdir, _state as Action <int, string>, _lisMicaps, _risMicaps); if (result != null) { foreach (string file in result) { if (Path.GetFileName(file).Contains("累计方差贡献")) { Process.Start(file); } } } } catch (System.Exception ex) { _state(0, ex.Message); } }
private void DoWork() { string[] lfiles = GetFileNames(listBox1); string[] rfiles = GetFileNames(listBox2); if (!CheckFiles(lfiles, rfiles)) { return; } int leftBandNum = GetBandNo(comboBox1, Path.GetExtension(lfiles[0]) == ".000"); int rightBandNum = GetBandNo(comboBox2, Path.GetExtension(rfiles[0]) == ".000"); double leftRatio, rightRatio; TryGetRatio(txtleftRatio, out leftRatio); TryGetRatio(txtrightRatio, out rightRatio); string outdir = txtOutputDir.Text; bool lisMicaps = false, risMicaps = false; if (Path.GetExtension(lfiles[0]) == ".000") { lisMicaps = true; } if (Path.GetExtension(rfiles[0]) == ".000") { risMicaps = true; } string[] fillvalueR = null; if (!string.IsNullOrEmpty(txtFillvaluesR.Text)) { string[] parts = txtFillvaluesR.Text.Split(','); double fv; foreach (string part in parts) { if (double.TryParse(part, out fv)) { throw new ArgumentException("填充值设置无效!" + part); } } if (parts.Length > 0) { fillvalueR = parts; } } string[] fillvalueL = null; if (!string.IsNullOrEmpty(txtFillvaluesL.Text)) { string[] parts = txtFillvaluesL.Text.Split(','); double fv; foreach (string part in parts) { if (double.TryParse(part, out fv)) { throw new ArgumentException("填充值设置无效!" + part); } } if (parts.Length > 0) { fillvalueL = parts; } } var context = TaskScheduler.FromCurrentSynchronizationContext(); var token = Task.Factory.CancellationToken; Task task = Task.Factory.StartNew((arg) => { Task.Factory.StartNew(() => { toolStrip1.Enabled = false; }, token, TaskCreationOptions.None, context); try { CloudParaFileStatics st = new CloudParaFileStatics(); string[] result = st.FilesSVDStat(lfiles, leftBandNum, fillvalueL, rfiles, rightBandNum, fillvalueR, leftRatio, rightRatio, outdir, arg as Action <int, string>, lisMicaps, risMicaps); if (result != null) { foreach (string file in result) { if (Path.GetFileName(file).Contains("累计方差贡献")) { Process.Start(file); } } } } catch (Exception ex) { Action <int, string> process = arg as Action <int, string>; if (process != null) { process(0, ex.Message); } } }, _state); task.ContinueWith((t) => { toolStrip1.Enabled = true; }, context); }