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();
        }

posted @ 2015-08-17 09:26  佳序  阅读(217)  评论(0编辑  收藏  举报