从事件推送通知更新UI已收到 [英] Update UI from event push notification Received

查看:79
本文介绍了从事件推送通知更新UI已收到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在创建一个连接到在线平台的Win 8 metro应用程序。


在应用程序中用户可以创建连接到在线平台的帐户。当平台中有新内容时,通过平铺更新推送通知按下toast通知。


我收集这些条目并将它们存储在用户存储文件夹中的xml文件中。


当用户打开应用程序时,他可以看到这些条目的摘要。


所以我创建了一个PushNotificationReceived事件,它接收到消息并创建一个toast和tile更新。此功能还会更新UI(列表视图,文本框,...),但后来出现错误: 
应用程序称为为不同线程编组的接口


如何解决这个问题?我是否必须在设置中设置一个参数,告诉应用在应用打开时更新用户界面?


 

解决方案

使用:

 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync()


然后它被发送到正确的线程。


Hi,

I'm creating a Win 8 metro app that is connected to an online platform.

In the app the user can create an account connected to the online platform. When there is something new in the platform it is push by push notification by a tile update an toast notification.

I collect al these entries and store them in an xml file in the user storage folder.

When the user opens the app, he can see a summary of these entries.

So I've created a PushNotificationReceived event which receives the message and create a toast and tile update. This function also updates the UI (listview, textbox,...), but then I get an error: The application called an interface that was marshalled for a different thread

How do I solve this issue? Do I have to set a parameter in the settings which tells the app to update the UI when the app opens?

 

解决方案

use:

CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync()

then it get send to the right thread.


这篇关于从事件推送通知更新UI已收到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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