RemoveWaypoint throws collection modified error
Investigating
Calling RemoveWaypoint on a MyBasicMissionAutopilot throws a System.InvalidOperationException since the collection is modified. The subject code is below- seems the raised event is altering the m_waypoints collection while it's still being iterated.
public void RemoveWaypoint(IMyAutopilotWaypoint waypoint) { foreach (MyAutopilotWaypoint waypoint2 in m_waypoints) { if (waypoint == waypoint2) { MyMultiplayer.RaiseEvent(this, (MyBasicMissionAutopilot x) => x.RemoveWaypoints, new int[1] { m_waypoints.IndexOf(waypoint2) }); } } }
Replies have been locked on this page!