[HELP]Invalid Operation Exception.

12/03/2008 22:33 tao4229#16
Quote:
Originally Posted by alexbigfoot View Post
lol?, u want to say, if only 1 thread is accessing the hashtable, it will never give the error?
If there is only one thread accessing the hashtable, nothing can be removed/added at the exact same time you're looping through it.
12/04/2008 05:31 Tw3ak#17
Quote:
Originally Posted by alexbigfoot View Post
does "lock statements" work in this case?
I posted in another thread how to use Singleton with standard lock plus double-check on hashtables and it works perfectly.

i believe it was in thread haydz made on how to make a hashtable or something i forget.
12/04/2008 17:15 alexbigfoot#18
tw3ak give me a link ,or what should i search to find it?
12/04/2008 17:30 tanelipe#19
Search for threads started by Haydz, the one about hashtables
12/04/2008 17:33 alexbigfoot#20
lemme look
12/04/2008 18:06 tanelipe#21
[Only registered and activated users can see links. Click Here To Register...]
12/04/2008 22:17 Incariuz#22
Ok... So I think I'm understanding this a bit better. Still don't want to jump into the lock procedure just incase. From what I gather. This line in itself is what accesses the hashtable.

Code:
foreach (DictionaryEntry DE in AllChars)
for

Code:
public static Hashtable AllChars = new Hashtable();
I ran through my character.cs to find over 20 sections involving that one hashtable. Information revolving around damage dealt, lvling up, mobs, NPC's, skills, etc...

Now I know you guys said it's best to have seperate hashtables for each task correect? Excuse me if I'm wrong, so much reading, it's hard to keep track of everything. But in such a case, could I merely create new hashtables for each individual action, and if so, would this require any changes elsewhere?

Any insight is appreciated, and I apologize for being a pain in the ass, I just don't want to take any durastic measures unless needed. And on my time schedule the past day or two, it's hard for me to really dive into tons of reading all at once, so it's hard to make sense of it when only taking partial info every so often.
12/05/2008 00:28 InfamousNoone#23
Quote:
Originally Posted by Incariuz View Post
Ok... So I think I'm understanding this a bit better. Still don't want to jump into the lock procedure just incase. From what I gather. This line in itself is what accesses the hashtable.

Code:
foreach (DictionaryEntry DE in AllChars)
for

Code:
public static Hashtable AllChars = new Hashtable();
I ran through my character.cs to find over 20 sections involving that one hashtable. Information revolving around damage dealt, lvling up, mobs, NPC's, skills, etc...

Now I know you guys said it's best to have seperate hashtables for each task correect? Excuse me if I'm wrong, so much reading, it's hard to keep track of everything. But in such a case, could I merely create new hashtables for each individual action, and if so, would this require any changes elsewhere?

Any insight is appreciated, and I apologize for being a pain in the ass, I just don't want to take any durastic measures unless needed. And on my time schedule the past day or two, it's hard for me to really dive into tons of reading all at once, so it's hard to make sense of it when only taking partial info every so often.
You could queue hashtable loops so they execute on one thread dequeuing them, or you could do what I do, avoid the hashtable class all together unless you know it won't be accessed on two threads at the same time in a loop.