wpf 的dispatcher
wpf项目中后台代码调用界面控件时,会提示进程调用的错误。
private Thread JxThread = null; //定义线程
private DataLoading.Loading nLoadW=new DataLoading.Loading();
private void ShowMessage() //要让主线程完成的事情
{
nLoadW.Dispatcher.BeginInvoke(new Action(() =>
{
nLoadW.Left = MWLeft;
nLoadW.Top = MWTop;
nLoadW.Show();
}));
System.Windows.Threading.Dispatcher.Run();
}