public bool RemoveInstance(int uuid) { if (mFullInstances == null || VisibleInstances == null) { return(false); } lock (mFullInstances) { M2RenderInstance inst; if (mFullInstances.TryGetValue(uuid, out inst) == false) { return(false); } --inst.NumReferences; if (inst.NumReferences > 0) { ++inst.NumReferences; return(false); } mFullInstances.Remove(uuid); inst.Dispose(); } lock (VisibleInstances) VisibleInstances.RemoveAll(inst => inst.Uuid == uuid); return(mFullInstances.Count == 0); }