void removeMenu_Click(object sender, EventArgs e) { if (commandList != null) { lock (commandList.SyncRoot) { List <IMacroCommand> removeList = new List <IMacroCommand>(); foreach (int index in table.SelectedIndicies) { removeList.Add(commandList[index]); } for (int i = 0; i < removeList.Count; i++) { commandList.Remove(removeList[i]); } } } }