public T GetObject() { lock (liveObjects) { // Check if first allocator is ready for reuse if (liveObjects.Count > 0) { var firstAllocator = liveObjects.Peek(); if (firstAllocator.Key <= GraphicsDevice.GetCompletedValue()) { liveObjects.Dequeue(); ResetObject(firstAllocator.Value); return(firstAllocator.Value); } } return(CreateObject()); } }