lundi 11 mai 2015

Load BitmapImage in background thread causes UI thread to stutter

I have a bit of code which loads a BitmapImage in the background, freezes it, and sends it off to the UI thread. However, even without sending to the UI thread, the act of loading a JPG into a BitmapImage causes the UI to stutter, even though it's happening on a background thread.

On reading about BitmapImage, it seems it might be the case that even if in a background thread, BitmapImage will use the Dispatcher and therefore run at least part of it's loading process in the UI thread.

This is pretty bad news for my animation capability, as it stutters and stalls on loading images in the background. As far as my code is concerned, the only bit to run in the UI thread is setting the 'Source' property on an Image to be the BitmapImage.

So, simple question, how can I load up a JPG into a BitmapImage without touching the UI thread?

Aucun commentaire:

Enregistrer un commentaire