The images are different in size, but not formats.
I don't have an issue if the images takes long to load, but is there maybe something I can do to not make the application unresponsive? If I can do something of that sort I think I should be O.K.
Hi to all,
I have a small WPF application that loads Departments and Items from my database. I have images for both departments and items, but it seems to me that the images takes a very long time to load.
What is the fastest and best way to load images in WPF. How do I load images asynchronously? If at all possible?
Any help would be appreciated. Code to load departments below:
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
windows applications are usually single threaded, so when they are busy processing information or whatever the application will become unresponsive. Application.DoEvents() will process any mouse clicks scroll wheen movement etc. and make the application more responsive, HOWEVER while this does not make the application multithreaded it will allow a user to click "Download" again, unless you have disabled it on first click. The application will still respond to events but care must be taken about users abusing the added functionality (ie. disable click once type buttons) This will also allow the form to redraw itselft, allowing for progress bar updates etc. Well to be honest you can update the progress bar as much as you like, but without a call to Application.DoEvents() the form will not redraw itself and your progress bar is useless. Care should be given about the frequency of calling the event however, since it does have a high overhead. I will send some samples as soon as I can.
LordWabbit,
I decided to go with Threading and was wondering if you could help me in this regard. I got the application to work using threading, but it does not display any pictures untill all of them are ready. Can I display images as they become available?
If you could help me with this last question I would really be greatful!
All you need to do is call Application.DoEvents so that the parent thread can update it's display (ie. the form). Not sure exactly where you would place it in your code excerpt (will need to see some more of the code). You might want to take a look at the System.ComponentModel.Back
Business Accounts
Answer for Membership
by: LordWabbitPosted on 2009-08-07 at 05:05:03ID: 25041792
are the pictures of different formats and sizes - are they being reformatted each time they are loaded from the database? Is the image server slow? Try timing the length it takes to get the image from the image server, that might be what is taking the longest time, and that means you can't really do much to your code to speed that up, EXCEPT to cache the images locally, but that means when an image is changed on the image server your application will not pick up the new one. A way around that is to flush images older than one hour out of your cache (which can be done with a seperate application).