/// <summary> /// 异步载入窗口数据时显示加载窗口 /// </summary> private void RunTaskMethod() { try { var PendingBox = PendingBoxX.Show("正在加载武器数据,请稍等。", "Loading~", this); var task = Task.Factory.StartNew(() => WeaponAndSkill.LoadWeaponPanelSimulator()); var act = new Action(() => { try { while (true) { if (!task.IsCompleted) { continue; } var excelReader = task.Result; if (excelReader.HasError) { throw new Exception(excelReader.ErrorMsg); } Fc.GetSearchTipList(excelReader.WeaponList.ObjList); WeaponSkillList.AddRange(excelReader.SkillList.ObjList); WeaponSkillNameList.AddRange(excelReader.SkillList.ObjList.GroupBy(x => x.Extra_Description + x.Main_Description).Select(x => x.Key).ToList()); PendingBox.Close(); return; } } catch (Exception ex) { MessageBoxX.Show("子线程错误:" + ex.Message, "ErrorMessage", MessageBoxButton.OK, MessageBoxIcon.Error); Application.Current.Dispatcher.Invoke(new Action(this.Close)); } }); var thread = new Thread(new ThreadStart(act)); thread.Start(); } catch (Exception ex) { MessageBoxX.Show("打开窗口时发生错误:" + ex.Message, "ErrorMessage", MessageBoxButton.OK, MessageBoxIcon.Error); this.Close(); } }