public void RemoveListener(IGroupListener listener) { lock (this) { this.listeners.Remove(listener); foreach (var id in this.groupIdsByListener[listener]) this.listenersByGroupId[id].Remove(listener); this.groupIdsByListener.Remove(listener); } }