I’m creating Windows Store application, that retrieves data asynchronously from web service and then updates the UI with the data. I’ve had several problems when accessing Application.Current.Resources in code(RPC_E_WRONG_THREAD).
Where I can find some explanation on how the app in launched, which threads are spawned during the app lifetime, and what I can do and access, and what can’t?
Windows Store applications follow the WPF threading model in which there is a single UI thread called the Dispatcher. All UI updates/modifications/etc must occur on the dispatcher thread. The error you are getting is that you’re trying to update the UI on a background thread.
.Net 4.5 uses a new async/await mechanism for managing asynchronous calls. So:
What is happening under the hood is that an asynchronous method is being generated by the compiler so that you don’t block the UI thread.
I suspect that you’re trying to access Access items that are expecting to be retrieved by the Dispatcher and this is why you’re erroring.