UWP中是否存在Application.Current.Dispatcher.Invoke(例如WPF)的类似物?Application.Current.Dispatcher.Invoke(() =>
{
//some code here
});
答案 0 :(得分:3)
Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
// Do your stuff here
});
这将在UI线程上运行您的代码,将CoreDispatcherPriority.Normal
更改为您喜欢的样式。
答案 1 :(得分:-1)
扩展Lloyd的回答:
async void SomeVoid(object sender, ElapsedEventArgs e) {
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
//Your code here
});
}