// This event handler is where the time-consuming work is done. private void ConstructSections_DoWork(System.Object sender, DoWorkEventArgs e) { BackgroundWorker worker = (BackgroundWorker)sender; var errorCenterLine = new Dictionary <Line, string>(); string errorMsg = ""; for (int i = 0; i < _count; i++) { var axis = _centerLines[i]; var cenA = SubgradeSection.Create(_docMdf, axis, out errorMsg); if (cenA != null) { cenA.CenterLine.UpgradeOpen(); cenA.ClearXData(true); var succ = cenA.CalculateSectionInfoToXData(errorMsg); if (succ) { cenA.FlushXData(); SectionAxes.Add(cenA); } else { errorCenterLine.Add(axis, errorMsg); } cenA.CenterLine.DowngradeOpen(); } else { errorCenterLine.Add(axis, errorMsg); } // 显示进度 worker.ReportProgress(i); } // 列出出错的断面 if (errorCenterLine.Count > 0) { _docMdf.WriteLineIntoDebuger("提取出错的断面:"); _docMdf.WriteLineIntoDebuger("序号 起点 终点 报错"); int index = 0; var acPoly = new Polyline(); foreach (var ecl in errorCenterLine) { var pt = new Point2d(ecl.Key.StartPoint.X, ecl.Key.StartPoint.Y); acPoly.AddVertexAt(index, pt, 0, startWidth: 0, endWidth: 0); _docMdf.WriteLineIntoDebuger(index + 1, ecl.Key.StartPoint, ecl.Key.EndPoint, ecl.Value); index += 1; } } }