I'm trying to get a lot of images from a webserver, so not to overload the server with hundreds of requests per second I only let a few through which is handled in WebService. The following code is on the object that saves the image, and where all the binding goes to.
ThreadStart thread = delegate()
{
BitmapImage image = WebService.LoadImage(data);
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
{
this.Image = image;
}));
};
new Thread(thread).Start();
The image is loaded just fine, the UI works fluidly while the image loads, however this.Image = image
is never called. If I use Dispatcher.CurrentDispatcher.Invoke(..)
the line is called, but doesn't work for setting the Image.
Why doesn't the dispatcher invoke my action?