windows-8 - CoreDispatcher.HasThreadAccess 的属性是什么?

标签 windows-8 windows-runtime windows-store-apps

我是 Windows 的新手,我正在尝试了解 API。 Windows 运行时 API 提供了 CoreDispatcher.HasThreadAccess 属性,但文档中对它的描述非常模糊:

"Gets a value that specifies whether the event dispatcher provided by this instance of CoreWindow has access to the current thread or not."

当它返回 false 时是什么意思?用户工程师何时以及为什么会使用这种方法?

最佳答案

它告诉您运行代码的线程是否可以安全地更新 UI。将其与 Winforms 中的 Control.InvokeRequired 和 WPF 中的 Dispatcher.CheckAccess 进行比较。

当它返回 false 时,您必须使用 Dispatcher.RunAsync() 来确保您的代码在正确的线程上运行。

关于windows-8 - CoreDispatcher.HasThreadAccess 的属性是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17666545/

相关文章:

c# - 如何解析 Windows 应用商店应用程序中的 HTML?

c# - 检测项目是否正在为 windows 8 或 wp 编译

xaml - 为什么任务栏中的应用程序图标在 Windows 10 中不透明?

c# - 将文件复制到 metro-style-app 的安装目录

.net - 如何在 WinRT 应用程序中创建自签名证书?

ssl - 为 ssl 连接动态生成的证书

c# - FileIO.WriteAsync 挂起

javascript - 如何使用 Windows 8 JSON.parse 将 JSON 文本反序列化为日期类型?

c# - 将磁贴固定到开始屏幕上的选定位置(以编程方式)Windows 8

uwp - 适用于 Windows 10 的 UWP 应用程序的正确 appxmanifest 证书是什么?