I use a player.io game timer like this: AddTimer(Update, 1000);
and use player.ios public override void GotMessage(Player player, Message m){....} to process messages
Update is capable of deleting objects if they've become too old as well as creating new ones. Meanwhile GotMessage depends on the state of these same objects and is also capable of deleting/adding new ones. I'd just assumed that player.io would be single threaded server side no matter what so during GotMessage my update function would stop running until it was through. However, I was getting null object reference errors while debugging GotMessage so I set breakpoints inside both it and Update and found that Update was still getting called even while I was in the middle of GotMessage.
What's the proper way to handle this? Should I start using locks? Although it occurs to me that then I'd be pausing Update so if I wanted an object to disappear after 10 seconds it wouldnt be precise. Should I stop judging lifespan by the number of times Update has been called and instead use DateTime?