Skip to content

Commit

Permalink
Avoid collection modification
Browse files Browse the repository at this point in the history
  • Loading branch information
dalyIsaac committed May 18, 2024
1 parent f3628a4 commit deb59c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Whim/Store/MonitorSector/MonitorSector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public override void Initialize()

public override void DispatchEvents()
{
foreach (EventArgs eventArgs in _events)
// Use index access to prevent the list from being modified during enumeration.
for (int idx = 0; idx < _events.Count; idx++)
{
EventArgs eventArgs = _events[idx];
switch (eventArgs)
{
case MonitorsChangedEventArgs args:
Expand Down
4 changes: 3 additions & 1 deletion src/Whim/Store/WindowSector/WindowSector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ public override void Initialize()

public override void DispatchEvents()
{
foreach (EventArgs eventArgs in _events)
// Use index access to prevent the list from being modified during enumeration.
for (int idx = 0; idx < _events.Count; idx++)
{
EventArgs eventArgs = _events[idx];
switch (eventArgs)
{
case WindowAddedEventArgs args:
Expand Down

0 comments on commit deb59c9

Please sign in to comment.