WinRT中的全球调度员?

Ara*_*ami 6 xaml microsoft-metro windows-8 windows-runtime winrt-xaml

我有一些看起来像这样的WP7代码:



using System.Windows;
using System.Windows.Threading;

public static class GlobalDispatcher
{
    public static Dispatcher Current { get { return Deployment.Current.Dispatcher; } }
}

Run Code Online (Sandbox Code Playgroud)

WinRT中的等价物是什么?是否没有全局可访问的Dispatcher(或CoreDispatcher)对象?

Jef*_*and 8

你会想要使用Window.Current.Dispatcher.


eFl*_*loh 6

只是添加这个作为答案,因为它更好地解决了我认为的问题:

如果应用程序没有集中,Window.Current为null,因此当涉及到用户时会给您带来麻烦;)

CoreApplication.MainView.CoreWindow.Dispatcher不为null ...

- 杰里米怀特2013年8月4日13:09