我一直在开发一个消费Windows Runtime组件(WRC)的Windows Phone应用程序。由非UI线程访问的函数需要使用回调来访问Windows Phone应用程序。
它抛出了 System.AccessViolationException 异常。然后我使用了。
在C++代码(WRC)中。但这也会抛出Platform::AccessDeniedException异常。
如何在Windows Phone中获取用于UI的Dispatcher?
void WControlPointCallback::OnListChange(char *pFriendlyName)
{
// Callback function to access the UI
pCallBack->AlertCaller("Message");
}
一开始没有使用Dispatcher,它抛出了
。然后我参考了this, this和this。我尝试从UI获取Dispatcher。
Platform::AccessDeniedException
var dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
它抛出了 System.AccessViolationException 异常。然后我使用了。
pDispatcher = Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher;
在C++代码(WRC)中。但这也会抛出Platform::AccessDeniedException异常。
如何在Windows Phone中获取用于UI的Dispatcher?
代码标签
来强调您认为很重要
的单词
。代码标签是用于代码的。 - Charles