WPF线程外激活UI响应

        void UIAction(Action action)  

        {  

            System.Threading.SynchronizationContext.SetSynchronizationContext(new System.Windows.Threading.DispatcherSynchronizationContext(App.Current.Dispatcher));  

            System.Threading.SynchronizationContext.Current.Post(_ => action(), null);  

        }  

直接调用即可

UIAction(() =>  
            {  
              
                txtTip.Text = str;  
                 
            }  
                );  

From: https://blog.csdn.net/shaynerain/article/details/102637269

发布了123 篇原创文章 · 获赞 59 · 访问量 168万+

猜你喜欢

转载自blog.csdn.net/shaynerain/article/details/102637269