本文介绍了Application.Current.Dispatcher.Invoke UWP模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
UWP中是否存在Application.Current.Dispatcher.Invoke(例如WPF)的类似物? Application.Current.Dispatcher.Invoke(()=>{//这里有一些代码});
Which is an analogue of Application.Current.Dispatcher.Invoke (such as WPF) exists in UWP?Application.Current.Dispatcher.Invoke(() => { //some code here });
推荐答案
Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
// Do your stuff here
});
这将在UI线程上运行您的代码,将 CoreDispatcherPriority.Normal
更改为您喜欢的.
This will run your code on the UI thread, change the CoreDispatcherPriority.Normal
to your liking.
这篇关于Application.Current.Dispatcher.Invoke UWP模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!