0

i have an picture.jpg which is 11 megabytes size. And i'd like to put this image in image container

BitmapImage bmp = new BitmapImage(new Uri(Path));
image1.Source = bmp;

so its cost me about 0.5 seconds UI freeze.

How can I avoid such a freeze?

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
Xa-Xa-Xa
  • 1
  • 1
  • have you tried calling `image1.BeginInit();` before setting the Source and then calling `image1.EndInit()`? If it does not help, async loading should be performed. – King King Sep 27 '14 at 11:08
  • Can you plese give me an example of async loading ? – Xa-Xa-Xa Sep 27 '14 at 11:09
  • what about Googling? – King King Sep 27 '14 at 11:12
  • 1
    Oh sorry, i finally get how stackowerflow works, you ask question, and receive an answer "go to google". Was very useful thanks you . – Xa-Xa-Xa Sep 27 '14 at 11:17
  • See [here](http://stackoverflow.com/a/16041810/1136211). – Clemens Sep 27 '14 at 11:51
  • 1
    @Xa-Xa-Xa, you do some research yourself and then come to SO with what you've tried! SO isn't a site to come to and say "GIVE ME CODE", it's a community of people helping each other with problems. If someone came to you and asked for help with their Maths homework and hadn't attempted any of it themselves but expected you to do it all, how would you feel? You'd be more willing to help if they had made an effort. – ProgrammingLlama Sep 27 '14 at 12:08
  • 1
    Well, would you look at that? A query formed of what you want to do that provides solutions for what you want to do: https://www.google.com/search?btnG=1&pws=0&q=wpf+threaded+image+load&gws_rd=ssl#pws=0&q=wpf+async+image+load – ProgrammingLlama Sep 27 '14 at 12:10

0 Answers0