Reputation: 3003
I have the background task, and I want to show a message dialog in this background task in some situations like below.
public sealed class TestTask : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance)
{
dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; // -> Crash this line
}
}
As you can see from Problems with show dialog on Background task in windows phone 8.1 when I trying to access the UI thread from background task I want to use CoreDispatcher
.
But when I want to use CoreDispatcher
in UWP background task, CoreWindows.GetForCurrentThread().Dispatcher
is null in constructor and run method, and I get null pointer exception with below message
Object reference not set to an instance of an object
Is something has changed in windows phone 10 (UWP) from Windows phone 8.1?
Upvotes: 0
Views: 894
Reputation: 174
Just to clear up this question, based on the comments here are your options.
If none of the above options suits you it's time to reconsider your current scenario...
Upvotes: 1