C#地铁应用UI更新 [英] C# Metro App UI update

查看:229
本文介绍了C#地铁应用UI更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是一样的为链接

My problem is just the same as this link.

我工作在新的WinRT在C#中(win8的发布预览)城域应用。
的问题是:我的应用我的程序运行的在后台线程从服务器接收邮件(其实,我移植一个XMPP客户端应用程序)。一些信息应在用户界面进行更新。

I am working on the new WinRT for Metro Applications in C#(win8 release preview). The problem is: My app My program runs a thread in the background which receives messages from the server(In fact, I ported a XMPP client app). Some information should be updated in the UI.

我曾尝试该链接。第二种方法似乎会为我工作,但我发现的没有Dispatcher.Invoke(...)在VS2012RC智能感知,这意味着不存在这种扩展方法。

I have tried that link. The second method seems would work for me, but I has found there is no Dispatcher.Invoke(...) in the VS2012RC intellisense which means there is no this extension method.

仔细搜索后,我想也许链接 能帮助我。但我不知道如何与我在这种情况下应用程序启动(因为我是C#初学者)。

After searching carefully, I think maybe this link can help me. But I have no idea how to start with my application in this scenario (since I am a beginner in C#).

你能不能给我一些建议吗?如果你表现出一定的代码片段,这将有助于我这么多,我将不胜感激。
非常感谢

Can you give me some advice? I would appreciate if you show some code snippet that would help me so much. Thanks a lot.

推荐答案

在某处,UI线程运行:

Somewhere in your UI thread run :

CoreDispatcher dispatcher = Windows.UI.CoreWindow.GetForCurrentThread().Dispatcher;



然后从你的后台线程调用 RunAsync 功能在调度员刚创建变量。

dispatcher.RunAsync(DispatcherPriority.Normal, <delegate to run on UI thread>);

这篇关于C#地铁应用UI更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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