CoreWindow::GetCurrentForThread() 始终为 NULL

编程入门 行业动态 更新时间:2024-10-25 06:25:32
本文介绍了CoreWindow::GetCurrentForThread() 始终为 NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试在 Windows Phone 8 上使用 C++ 获取 CoreDispatcher,以便我可以将工作项提交到 UI 线程 Dispatcher,以便我可以更新 UI 线程上的 UI 元素.但是,当我调用 CoreWindow::GetCurrentForThread() 时,我会返回 NULL.在 文档 中,它指出WP8 支持此功能.只要我为当前窗口获取NULL,我就无法从中获取当前的Dispatcher;有谁知道如何在 WP8 上获取当前的 Dispatcher?

I'm trying to get the CoreDispatcher in C++ on Windows Phone 8 so that I can submit work items to the UI thread Dispatcher so I can update UI elements on the UI thread. However, when I call CoreWindow::GetCurrentForThread(), I get NULL back. In the documentation it states that this is supported on WP8. As long as I'm getting NULL for the current Window, I can't get the current Dispatcher from it; does anyone know how to get the current Dispatcher on WP8?

推荐答案

我用过

await CoreApplication.Views.First().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    //your code here
                });

这篇关于CoreWindow::GetCurrentForThread() 始终为 NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 13:51:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117699.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CoreWindow   GetCurrentForThread   NULL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!