|
-
November 27th, 2008, 06:22 AM
#1
Asynchronously Filling List in random order
Hey there,
Ive got a problem with the current task im working on, and im not sure how is the best way to solve it.
Basically i have an asynchronous loader that loads images from an XML file, so there could be 1 or 100 image links contained. Now to make it slightly harder they need to maintain the order that they are on the XML file. The Images are contained within an object that is partially populated from the XML data, then it has a list<Image> that should be filled with the loaded images as they complete.
So i thought the easiest way to do this would be to make sure that each image has an index of where it resides, so when its loaded it knows where to go in the list. So if there was 100 images and lets say number 67 completed first i was assuming it would just allow me to put it in there, and then as the others fly in it would eventually reach 100, just they get put inserted in a random order.
Now it loves to spit out an error telling me that:
"Index must be within the bounds of the List."
So im assuming that it will only let me insert into an already existing index in the list OR at the end of the list... so is my understanding correct, and if so is there any way to achieve what i want?
I was thinking about maybe having a loop so if you try to insert at an index > list count then it would fill in dummy data to flesh out until that count, but it sounded a little inefficient, so just wanted to see if anyone could think of a better way...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|