some extra info on what 12tails just said ,
The problem is that, if you are doing a foreach loop over a collection, and another thread modifies the collection, the enumerator used in foreach is no longer valid. This will cause an exception to throw at that point.
maybe you can use the lock statement to but either way it works but you have to lock the dictionaries while reading/modifying to reach the thread safe point and to avoid such errors
and remember try to keep the lock blocks as small as possible, but make sure they are always locking around the shared resources correctly.
some extra info on what 12tails just said ,
The problem is that, if you are doing a foreach loop over a collection, and another thread modifies the collection, the enumerator used in foreach is no longer valid. This will cause an exception to throw at that point.
on how to fix it.
you can do something like this .
maybe you can use the lock statement to but either way it works but you have to lock the dictionaries while reading/modifying to reach the thread safe point and to avoid such errors
and remember try to keep the lock blocks as small as possible, but make sure they are always locking around the shared resources correctly.
Good Luck .
Here is the code i found in that error.....
foreach (Game.Entity monster in Owner.Map.Entities.Values)
{
if (Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X,
Owner.Entity.Y) <= Constants.nScreenDistance &&
!Contains(monster.UID))
{
if (!monster.Dead)
{
monster.SendSpawn(Owner);
}
}
}
hmmm.. what things to do. yes I get some ideas but, Im sorry for that I just really want to learn on how to do this....
foreach (Game.Entity monster in Dictionary.ThreadSafeDictionary(Owner.Map.Entities ).Values)
{
if (Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X,
Owner.Entity.Y) <= Constants.nScreenDistance &&
!Contains(monster.UID))
{
if (!monster.Dead)
{
monster.SendSpawn(Owner);
}
}
}
and you'll never get that error again
a small edit for more information about it :
the code snip that i provided up there should lock the original dictionary which is (Owner.Map.Entities) to make sure its protected while copying it creates a new empty dictionary copies the original dictionary(Owner.Map.Entities)key's/value's to the new dictionary and returns the created copy not the original dictionary ,
so when you do the for each you are doing it using the copy not the original which mean if somehow you modify the original dictionary while doing a for each you are not gonna get that error and the original dictionary should be secured all the time by locking it every time you try to read it/modify it .
create a static class and call it Dictionary and copy paste the thread safe dictionary void that i provided in the earlier replay to it ,
so it looks like this
and change the void to look like this ,
and you'll never get that error again
a small edit for more information about it :
the code snip that i provided up there should lock the original dictionary which is (Owner.Map.Entities) to make sure its protected while copying it creates a new empty dictionary copies the original dictionary(Owner.Map.Entities)key's/value's to the new dictionary and returns the created copy not the original dictionary ,
so when you do the for each you are doing it using the copy not the original which mean if somehow you modify the original dictionary while doing a for each you are not gonna get that error and the original dictionary should be secured all the time by locking it every time you try to read it/modify it .
Comands for 12talis source (5369) 08/14/2012 - CO2 PServer Guides & Releases - 28 Replies Here all commands
How use?
Go to source>Instances>Chat>Commands.cs
And read!!!!!!:mad:
[Guide] How set up 12talis 5369 source 01/10/2012 - CO2 PServer Guides & Releases - 120 Replies Read his one most important part of his guide
http://www.elitepvpers.com/forum/co2-pserver-disc ussions-questions/177002-ask-yourself-before-you-s tart-trying-make-server.html
First download source http://www.elitepvpers.com/forum/co2-pserver-guide s-releases/1174175-release-virtual-legends-source- 5369-a.html
Second get client http://www.megaupload.com/?d=VZNKMSV0
Help me source 5369! 05/13/2011 - CO2 Private Server - 5 Replies In the configuration there is no where to put the name of the database or login and password for app serv help plz:o sorry my bad english
[Release] Virtual Legends Source (5369) 05/12/2011 - CO2 PServer Guides & Releases - 162 Replies Yo...
READ THIS >>> The source is unfinished and requires C# KNOWLEGE <<<
since this is going to happen soon or later, i'm going to release this source
//CREDITS:
-impulse- > Source base released version 5165
-Shunsui- (Jose) > a friend who coded this source with me
12tails (me/Leo) > for coding and release
Spirited / Fang > For give to us his character on real co to sniff packets hahahahaha