On Jun 20, 4:34*am, Marc Gravell <marc.grav...@gmail.comwrote:
I would imagine that once you have loaded each image you can just use
something like:
// runs on worker thread
// .. load an image
this.Invoke((MethodInvoker) delegate {
* *// runs on UI thread
* *// add the image
* *imagelist.Images.Add(key, image);
* *// assign keys...});
// runs on worker thread
// .. load the next image
Marc
Thanks, that helped!
What I ultimately ended up with (in the body of my background worker's
doWork handler):
//for every filename in a list of filenames:
{
//del delegate will actually load the images into memory and
manipulate them
//into thumbnails when appropriate...
IAsyncResult ar = del.BeginInvoke(name, null, null);
//...and return the thumbnails here:
Image thumb = del.EndInvoke(ar);
string key = getKeyForFileName(name);
//pass the new thumbnail into the updater, which will update
//the image list on UI.
this.Invoke(updaterDel, key,thumb);
}
At first I did the image loading AND the updating from this.Invoke,
but the UI would be blocked until all images were loaded (that
behaviour is what started me to look at virtual mode in the first
place, way back), so I had the delegate load the image seperately,
then return it to the main thread to update the UI. I'm sure this code
can be cleaned up some more, but at least I have something working for
now. Clean up to come in the morning when I'm fresh!