I have been developing a Windows Phone application that consumes Windows Runtime component(WRC).A function accessed by a non-UI thread,needs to use a callback that access the Windows phone application.
void WControlPointCallback::OnListChange(char *pFriendlyName)
{
// Callback function to access the UI
pCallBack->AlertCaller("Message");
}
At first without using the Dispatcher it threw
Platform::AccessDeniedException
.
Then I referred to this, this and this. I tried to obtain the Dispatcher from the UI.
var dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
It threw System.AccessViolationException
.Then I used
pDispatcher = Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher;
in C++ code(WRC).But this too throws Platform::AccessDeniedException
.
How to obtain the Dispatcher for UI in Windows Phone?
code tags
to emphasizewords
that you think areimportant
. Code tags are for code. – Thibodeaux