I'm trying to update an Image in my UI from an event in a different thread. I'm using a Dispatcher (based on this question: Fire events from different thread) to do so, but still get the "The calling thread cannot access this object because a different thread owns it"-Error Message at i.Source = s;
. What's the proper way of doing this?
void OnEvent(object sender, EventArgs e)
{
ImageSource s = e.Image;
Dispatcher.BeginInvoke((Action)(
() => UpdateUI(myImage, s)
));
}
void UpdateUI(Image i, ImageSource s)
{
i.Source = s;
}
Thanks a lot for any suggestions!