tags:

views:

544

answers:

3
+2  A: 

Don't load all 200 mb of photos into the listbox all at once on your UI thread. Will the user be looking at 200 mb all at once? It'll take some work on your part, but you're going to need to do some delayed loading of the images from a background thread.

Greg D
Yes, user willbe looking at all the images into the listbox.Loading images into listbox is not a problem. iam using background thread for that. but the problem is while adding photos to the canvas. For adding also i used background worker.
+2  A: 

Take a look at this article (Advanced Techniques To Avoid And Detect Deadlocks In .NET Apps), it may help.

Lazarus
A: 

This looks like two questions, the first is that you are loading images in a background thread, but not doing it correctly; thus, the COM error. Double check that you are have a STAThread application and that the image loading thread is not interacting with the WPF dispatch thread incorrectly. Here's a discussion MTA vs. STA; however, WPF needs STA, and it's a loosing battle to fight it.

The second question seems to be how should one do this; that is, loading a bunch of images for display. I would look into using a lazy data binding of the ListView and let the virtualizing presenter that's built into is manage the loading/display of the images.

Here's some docs on using a view-model. The viewmodel could coordinate the image load and provide the ListView with a binding source that would automatically get the application working.

A simpler alternative might be to start up a background thread and load the images into an ObservableCollection<>, bind that to the ListView and let the framework deal with the display.

I second what Greg D said, loading 200mb of images sounds like a recipe for problems.

Scott