Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Metro应用程序用户界面更新_C#_Multithreading_User Interface_Microsoft Metro - Fatal编程技术网

C#Metro应用程序用户界面更新

C#Metro应用程序用户界面更新,c#,multithreading,user-interface,microsoft-metro,C#,Multithreading,User Interface,Microsoft Metro,我的问题和这个问题一样 我正在为C#中的地铁应用程序开发新的WinRT(win8发布预览版)。 问题是:我的应用程序我的程序在后台运行一个线程,它从服务器接收消息(事实上,我移植了一个XMPP客户端应用程序)。一些信息应该在UI中更新 我试过那个链接。第二种方法似乎适合我,但我发现VS2012RC intellisense中没有Dispatcher.Invoke(…),这意味着没有此扩展方法 仔细搜索后,我想这可能对我有帮助。但是我不知道如何在这个场景中启动我的应用程序(因为我是C#的初学者)

我的问题和这个问题一样

我正在为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。