Following this example (http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202967(v=vs.105).aspx) I have enabled my Windows Phone 8 app for push notifications. I can receive notifications and the callback method PushChannel_ShellToastNotificationReceived
is called. From the example, this method opens a message box with the notification contents.
Can I therefore assume that it is safe to execute UI related operations from the thread the callback is executed in? I see that the message box is wrapped in Dispatcher.BeginInvoke(() =>
, however I have no idea what thread this will be executed in, and what objects I should use from this thread.
PushChannel_ShellToastNotificationReceived
is always called by the OS when a push notification is received while your app is running so it will execute on a non-UI thread.Any UI related code that needs to be executed must be wrapped inside
Dispatcher.BeginInvoke(Action a)
otherwise you'll get anUnauthorizedAccessException
exception.