如果我尝试更新我的UI,则从Windows 8类库中收到此错误:
The application called an interface that was marshalled for a different thread.
由于Dispatcher.RunAsync
方法不可用,我无法解决问题。
答案 0 :(得分:0)
不是从其他线程更新UI的好方法。
为什么Dispatcher.RunAsync不可用?
this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
YourMethod();
});
或尝试用作等待任务:
this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
YourMethod()();
}).AsTask().Wait();
**this** is reference to **Window.Current**.