/// <summary> /// 导入新生数据 /// </summary> /// <param name="o"></param> private async void OnImportNewStudengts(object o) { if (AllowImport()) { ErrorMsg = string.Empty;//清楚所有的错误消息 if (ModernDialog.ShowMessage(string.Format("确定以 {0} 方式导入 {1} 批次吗?", ImporttypeValue, SelectPcdmItem.Pcdm), "消息", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { SplanshScreenWindow splan = new SplanshScreenWindow(); splan.Show(); controls.ProgressBar progressBar = ((controls.UserControl)o).FindName("progress") as controls.ProgressBar; progressBar.Height = 20; try { Progress<int> progress = new Progress<int>(); progress.ProgressChanged += (sender, args) => { progressBar.Value = args; }; await TaskEx.Run(() => { BeginImportNewStudents(progress); }); } finally { splan.Close(); progressBar.Height = 0; progressBar.Value = 0; } } } }