Max
❔ c# access variable from other thread
I've been searching the web for a while and I cant seem to access a variable like this:
img.Source = image;
where image comes from a different thread (Task.Run(...)
). I have tried
img.Dispatcher.Invoke(() => img.Source = image);
and
but both do not work.
Error: System.InvalidOperationException: "The calling thread cannot access this object because a different thread owns it."
Full code:
15 replies