Search code examples
c#multithreadingwindows-8xamarinxamarin.forms

Xamarin.forms giving "invalid cross thread access" Exception in windows8 emulator


Xamarin.forms is working fine in android phones but in window8 emulator it is not loading image and giving invalid cross thread access exception.

I'm using Embedded Image Technique, I'm storing all images in common folder and accessing from shared project.

snapshot of my project is as follows:

enter image description here

Error is As follows :

enter image description here

In window8 simulator images are not loading

enter image description here

Any help will be much appreciated.


Solution

  • This is because you are updating a UI element on a non UI thread, you want to use Device.BeginInvokeOnMainThread, like so:

    Device.BeginInvokeOnMainThread(() => MainPage.DisplayAlert("Boom", message, "Cancel"));