我是 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/