环境:WPF。弹窗,messageBox.show();
错误信息:调度程序进程已挂起,但消息仍在处理中;
解决方法:
Dispatcher.BeginInvoke(new Action(()=>{.........函数
}));
程序中有一个验证数据正确性,所以直接写在验证方法里。包住整个方法就可以了。
/// <summary>/// 支数据验证/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void ThisZhi_Change(object sender, TextChangedEventArgs e){Dispatcher.BeginInvoke(new Action(() =>{TextBox ThisTB = sender as TextBox;int InputNo = OPCommon.ConvertType.GetInt32(ThisTB.Text);List<int> GetListInt = BThisdianshuList.Select(x => x.zhiNo).ToList();GetListInt.Remove(InputNo);if (GetListInt.Count > 0 && (InputNo > GetListInt.Max() + 1 || InputNo == 0)){MessageBox.Show("数据录入失败,请检查数据。", "系统提示:", MessageBoxButton.OK, MessageBoxImage.Warning);ThisTB.Text = GetListInt.Max().ToString();}else if (GetListInt.Count == 0){ThisTB.Text = "1";}}));}
现在的错误是可控的: