I recently struggled quite a bit trying to get access to the UI dispatcher from a background thread. I had a scenario where when I receive a push notification, I had to update the XAML page UI. Obviously, I did not have access to the UI thread from the background thread so I binged quite a bit. Surprisingly, the documentation on this is not clear and I had to go through quite a bit of searching to find the right answer. Here it is for future reference:
1 2 3 4 5 | await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { // UI stuff here }); |
This was the exact issue I had and this fixed it. Thanks for the help.