public void Add(IMode mode) { if (_modes.Contains(mode)) { throw new Exception("Attempted to add mode " + mode.ToString() + ", already in mode queue."); } lock (_mode_lock_obj) { _modes.Add(mode); } //self.modes.sort(lambda x, y: y.priority - x.priority) _modes.Sort(); mode.ModeStarted(); if (mode == _modes[0]) { mode.ModeTopMost(); } }