Reputation: 37
I receive this error System.Runtime.InteropServices.COMException: 'The application called an interface that was marshalled for a different thread when run below code `
var image = await Globals.GetImage(attendance.ImageUrl);
if(image!= null)
{
MemoryStream ms = new MemoryStream();
image.CopyTo(ms);
** AttPhoto.Source = ImageSource.FromStream(() => ms); }**
}
`
in my static Globals class there is a static method that returns memorystream
Upvotes: 0
Views: 2966
Reputation: 13899
You can only update the UI from the main UI thread. If you are running code on a background thread and need to update the UI, you can try to add your code in Main thread.
On Maui,for how to invoke on the main thread , you can check here:
https://github.com/dotnet/maui/discussions/7518
Upvotes: 2