在WinRT的UI线程中运行code [英] Run code on UI thread in WinRT

查看:144
本文介绍了在WinRT的UI线程中运行code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我可以在WinRT中(Windows 8的地铁)UI线程上运行code。该调用方法不存在。

I want to know how I can run code on the UI thread in WinRT (Windows 8 Metro). The Invoke method does not exist.

推荐答案

使用:

这是你的UI线程,执行:

From your UI thread, execute:

var dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;

这是你的背景(非UI线程)

From your background (non UI thread)

dispatcher.RunAsync(DispatcherPriority.Normal, 
    <lambda for your code which should run on the UI thread>);

这应该工作在两个CP和以后版本。

That should work on both CP and later builds.

这篇关于在WinRT的UI线程中运行code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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