CoreWindow::GetCurrentForThread() 始终为 NULL [英] CoreWindow::GetCurrentForThread() always NULL

查看:33
本文介绍了CoreWindow::GetCurrentForThread() 始终为 NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆