Page 1 of 1

Is it safe to remove an entity in this manner?

Posted: Wed Jan 07, 2015 2:58 am
by jaja1
Question speaks for itself :)

Code: Select all

Entity.Space.Remove(Entity);
My server has been throwing Null Reference Exceptions on a particular line similar to the above and was wondering if that was the cause. I'm not too sure because sometimes it works and other times it doesn't. Sounds like race conditions I know - but my code is queued properly in a fiber pool and each call to this code is done through a new class instance, so there should be no unexpected access at any point.

Re: Is it safe to remove an entity in this manner?

Posted: Wed Jan 07, 2015 4:37 am
by Norbo
There is nothing inherently wrong with that snippet in isolation. If it's not a reliable failure, it does indeed sound like a race condition :)

Re: Is it safe to remove an entity in this manner?

Posted: Wed Jan 07, 2015 5:10 pm
by jaja1
Thank you Norbo :)
I think I might have found a logical error in my code that lead to duplicate instances of the the Entity but some of them were not assigned values to :lol: