C# Metro App UI update

假装没事ソ 提交于 2019-12-19 04:51:22

问题


My problem is just the same as this link.

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.

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.

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.


回答1:


Somewhere in your UI thread run :

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

Then from your background thread call the RunAsync function in the dispatcher variable you just created.

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


来源:https://stackoverflow.com/questions/10990152/c-sharp-metro-app-ui-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!