从非UI线程直接获取CoreWindow更容易。以下代码可以在任何地方使用,即使是GetForCurrentThread()或Window.Current返回null。CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, <lambda for your code which should run on the UI thread>);例如:CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // Your UI update code goes here! });您需要引用Windows.ApplicationModel.Core命名空间:using Windows.ApplicationModel.Core;
使用:从您的UI线程,执行:var dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;从你的背景(非UI线程)dispatcher.RunAsync(DispatcherPriority.Normal, <lambda for your code which should run on the UI thread>);这应该适用于CP和后期版本。