C#Metro应用程序用户界面更新
我的问题和这个问题一样 我正在为C#中的地铁应用程序开发新的WinRT(win8发布预览版)。 问题是:我的应用程序我的程序在后台运行一个线程,它从服务器接收消息(事实上,我移植了一个XMPP客户端应用程序)。一些信息应该在UI中更新 我试过那个链接。第二种方法似乎适合我,但我发现VS2012RC intellisense中没有Dispatcher.Invoke(…),这意味着没有此扩展方法 仔细搜索后,我想这可能对我有帮助。但是我不知道如何在这个场景中启动我的应用程序(因为我是C#的初学者) 你能给我一些建议吗?如果您能给我看一些代码片段,我将不胜感激。C#Metro应用程序用户界面更新,c#,multithreading,user-interface,microsoft-metro,C#,Multithreading,User Interface,Microsoft Metro,我的问题和这个问题一样 我正在为C#中的地铁应用程序开发新的WinRT(win8发布预览版)。 问题是:我的应用程序我的程序在后台运行一个线程,它从服务器接收消息(事实上,我移植了一个XMPP客户端应用程序)。一些信息应该在UI中更新 我试过那个链接。第二种方法似乎适合我,但我发现VS2012RC intellisense中没有Dispatcher.Invoke(…),这意味着没有此扩展方法 仔细搜索后,我想这可能对我有帮助。但是我不知道如何在这个场景中启动我的应用程序(因为我是C#的初学者)
非常感谢。在您的UI线程运行中的某个地方:
CoreDispatcher dispatcher = Windows.UI.CoreWindow.GetForCurrentThread().Dispatcher;
然后从后台线程调用刚刚创建的dispatcher
变量中的RunAsync
函数
dispatcher.RunAsync(DispatcherPriority.Normal, <delegate to run on UI thread>);
dispatcher.RunAsync(DispatcherPriority.Normal,);
在UI线程运行的某个地方:
CoreDispatcher dispatcher = Windows.UI.CoreWindow.GetForCurrentThread().Dispatcher;
然后从后台线程调用刚刚创建的dispatcher
变量中的RunAsync
函数
dispatcher.RunAsync(DispatcherPriority.Normal, <delegate to run on UI thread>);
dispatcher.RunAsync(DispatcherPriority.Normal,);
谢谢。我以后再试试。看这个。我想应该使用CoreDispatcherPriority而不是DispatcherPriority。谢谢。我以后再试试。看这个。我认为应该使用CoreDispatcherPriority而不是DispatcherPriority。