❔ 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:
where image comes from a different thread (
and
but both do not work.
Error:
Full code:
img.Source = image;where image comes from a different thread (
Task.Run(...)). I have triedimg.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: