Is this a bug with the Hashtable?

  • Thread starter Thread starter SP
  • Start date Start date
S

SP

I am developing a multithreaded AS2 server, when the service starts I read
an XML file and creates a hash table for the possible recipients.

During testing I noticed that "Blank" entries were appearing in my hash
table, they have no key or object associated with them (as seen in the watch
window) so I cannot remove them but the Length property recognizes them and
my loops try to process them.

I have tried everything to track this down, there is no pattern to them
appearing, It can happen after I have sent 1 file on the first thread or
after I have sent 1000 files across 10 threads.

has anyone had any problems like this ?
 
I am developing a multithreaded AS2 server, when the service starts I read
an XML file and creates a hash table for the possible recipients.

During testing I noticed that "Blank" entries were appearing in my hash
table, they have no key or object associated with them (as seen in the watch
window) so I cannot remove them but the Length property recognizes them and
my loops try to process them.

I have tried everything to track this down, there is no pattern to them
appearing, It can happen after I have sent 1 file on the first thread or
after I have sent 1000 files across 10 threads.

has anyone had any problems like this ?

More then likely, you have an error in your code. You either have a
threading issue, or a problem with your xml parsing/assignment logic.
It's very hard to tell from your post. I would try and isolate the
problem. First, I would probably eliminate the possibility of a
threading error. Move the code for parsing and building your
hashtable into a console application - single threaded. Run the
operation a bunch of times - in sequence, no threads. Do you still
get the bogus entries? Then you need to examine the logic for
building the hashtable. If you don't, then you need to examin your
threading logic - because you have a concurencey issue.
 
Tom,

The original AS2 server was single threaded and didn't have any issues. The
hash table is only written to once and then passed to each of the threads so
they can work out where their messages are going to.
I have tried "Synclock"ing the routine that the bug appears in but thats not
to say that the routine broke it, it is the only place the items in the
hashtable are enumerated.
All the info I have found about the hashtabel say that it should be
threadsafe if you are only reading from it.

I have stepped through the code that populates the table and it only add's a
single entry.
 
SP said:
During testing I noticed that "Blank" entries were appearing in my hash
table, they have no key or object associated with them (as seen in the
watch window) so I cannot remove them but the Length property recognizes
them and my loops try to process them.

The 'Hashtable' class does not provide a 'Length' property.

I suggest to post the code you are using to access the hash table and loop
through its entries. Note that hash tables are typically only used for
lookup based on keys, not indices.
 
Not possible to post the code really as its spread across 3 DLL's, as I said
I don't know when the extra entrys are being added to the hashtable so its
not

The best I can do is take a screen shot of the watch window. That shows the
extra entrys with no objects or keys so they cannot be removed. Can you post
pictures to this group ?
 
Back
Top