对于WPF来说更新UI使用到Dispatcher ,在UWP也一样,只是写法有以下差异而已。
WPF:
Application.Current.Dispatcher.Invoke(()=>{
//update UI code
});
UWP:
public async void Invoke(Action action, Windows.UI.Core.CoreDispatcherPriority Priority = Windows.UI.Core.CoreDispatcherPriority.Normal)
{
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Priority, () => { action(); });
}
调用示例:
this.Invoke(()=>
{
//update UI code
});