我的运行时后台任务应该更改桌面壁纸图像,但是当我尝试初始化一个新的BitmapImage时,我得到了这个例外:
System.Exception: The application called an interface that was marshalled for a different thread.
我试过这样做:
var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
var testBitImg = new BitmapImage();
});
但后来我得到了这个例外:
System.InvalidOperationException: A method was called at an unexpected time
我真的不知道这些例外是什么意思或如何修复它们?