问题
I am working on an Windows Phone 8 Application that uses mixed C# for UI and C++ for the underlying backed. I have some instances where I need to run some C++ code on the UI dispatcher thread (IE GetGeopositionAsync()).
I have tried a method of making a callback from C++ to C# that runs in the UI thread and then calls a C++ method and runs:
auto window = Windows::UI::Core::CoreWindow::GetForCurrentThread();
However this is returning null. Is there any way for me to accomplish this?
回答1:
I had a similiar problem some days ago, as it has always returned null. I ended up using in WinRT. According to MSDN (1, 2) you should be able to use this in WP8 as well.
CoreApplication.MainView.CoreWindow
来源:https://stackoverflow.com/questions/17244857/windows-phone-8-access-ui-dispatcher-in-c-code