Reputation: 5536
I have in my Windows Phone app several images that are binded to uri's this causes the UI threa to get blocked when all the images are downloaded. I cant create a bitmapImage instance on a different thread because I would get an "Invalid cross thread operation" exeption.
I tried downloading the image using a WebClient but there is no constructor that accepts a stream for BitmapImage.
Any thought as to how I can accomplish downloading images in the background?
thanks
Amit
Upvotes: 1
Views: 978
Reputation: 14882
You're still on the UI thread using WebClient. If you continue with that approach, you can also consider HttpWebRequest. Here's a working sample including resolution for the invalid cross-thread access exception.
WebClient, HttpWebRequest and the UI Thread on Windows Phone 7
Upvotes: 0
Reputation: 189525
In order to use a Stream
to provide the content for a BitmapImage
you create an instance using the default constructor then call SetSource
passing the stream:-
var bi = new BitmapImage();
bi.SetSource(myStream);
However I think you may be re-inventing the wheel here. Take a look the link below:-
Upvotes: 2