T
Tony
I have this problem - I have a hashtable, containing a list of filenames.
Every 60 seconds, I have a thread that enumerates thru this hashtable, and
based on some simple logic, some of the items in the hashtable has to be
removed.
But when I remove a pair from the hashtable, inside the enumeration loop, I
get an exception.
Why cant I remove from a hashtable, while enumerating ?
My code looks something like this :
for each r in camImages
if r.value = x then
camImages.remove(r.key)
end if
next
When the above code is running, the first time the "camImages.remove(r.key)"
line is run, I get an exception in the last line, containing "next".
Can someone explain to me what I am doing wrong ?
-
Regards,
Tony Fonager
Netcoders ApS
Every 60 seconds, I have a thread that enumerates thru this hashtable, and
based on some simple logic, some of the items in the hashtable has to be
removed.
But when I remove a pair from the hashtable, inside the enumeration loop, I
get an exception.
Why cant I remove from a hashtable, while enumerating ?
My code looks something like this :
for each r in camImages
if r.value = x then
camImages.remove(r.key)
end if
next
When the above code is running, the first time the "camImages.remove(r.key)"
line is run, I get an exception in the last line, containing "next".
Can someone explain to me what I am doing wrong ?
-
Regards,
Tony Fonager
Netcoders ApS