【发布时间】:2021-04-07 23:05:11
【问题描述】:
UWP中存在哪个Application.Current.Dispatcher.Invoke(如WPF)的类似物?Application.Current.Dispatcher.Invoke(() =>
{
//some code here
});
【问题讨论】:
UWP中存在哪个Application.Current.Dispatcher.Invoke(如WPF)的类似物?Application.Current.Dispatcher.Invoke(() =>
{
//some code here
});
【问题讨论】:
Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
// Do your stuff here
});
这将在 UI 线程上运行您的代码,将 CoreDispatcherPriority.Normal 更改为您喜欢的。
【讨论】:
扩展Lloyd的回答:
async void SomeVoid(object sender, ElapsedEventArgs e) {
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
//Your code here
});
}
【讨论】: