gpt4 book ai didi

windows-runtime - CoreWindow::GetCurrentForThread() 始终为 NULL

转载 作者:行者123 更新时间:2023-12-01 02:28:41 27 4
gpt4 key购买 nike

我正在尝试获取 CoreDispatcher在 Windows Phone 8 上的 C++ 中,以便我可以将工作项提交给 UI 线程 Dispatcher,以便我可以更新 UI 线程上的 UI 元素。但是,当我调用 CoreWindow::GetCurrentForThread() , 我得到 NULL背部。在 the documentation它声明这在 WP8 上受支持。只要我得到 NULL对于当前窗口,我无法获取当前 Dispatcher从中;有人知道如何在 WP8 上获取当前的 Dispatcher 吗?

最佳答案

CoreWindow::GetForCurrentThread()记录为返回:

The CoreWindow for the currently active thread.



如果您从没有 CoreWindow 的线程调用此函数(与任何非 UI 线程一样),则此函数将返回 nullptr .

假设应用程序已完成初始化并且有一个 View ,您可以通过 CoreApplication::MainView 从应用程序的主视图使用调度程序.或者,您可以通过 Dispatcher^将 UI 线程用于在非 UI 线程上执行的代码,以便在需要调用回 UI 线程时可以访问它。

关于windows-runtime - CoreWindow::GetCurrentForThread() 始终为 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14497147/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com