适用于 Windows Phone 8.1 的新 API

适用于 Windows Phone 8.1 的新 API

问题描述:

我正在尝试在 windows phone 8.1 中使用这两种方法(WP 8),但它给出了错误并且无法编译,很可能是因为它们被删除了.我尝试搜索新的 API,但找不到任何.这些还有哪些其他选择.

I am trying to use these two methods (of WP 8) in windows phone 8.1, but it gives error and doesn't compile, most probably becasue they are removed. I tried searching the new APIs but couldn't get any. What are other alternatives for these.

Dispatcher.BeginInvoke( () => {}); msdn 链接

System.Threading.Thread.Sleep(); msdn 链接

它们仍然适用于 Windows Phone 8.1 SIlverlight 应用程序,但不适用于 Windows Phone 商店应用程序.Windows 应用商店应用的替代品是:

They still exists for Windows Phone 8.1 SIlverlight Apps, but not for Windows Phone Store Apps. The replacements for Windows Store Apps is:

Sleep(参见 Windows Store .NET 中的 Thread.Sleep 替换):

Sleep (see Thread.Sleep replacement in .NET for Windows Store):

await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(30));

Dispatcher(参见如何部署.Current.Dispatcher.BeginInvoke 在 Windows 商店应用程序中工作?):

Dispatcher (see How the Deployment.Current.Dispatcher.BeginInvoke work in windows store app?):

CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { });