stride3d/stride · error · InvalidOperationException
Multiple items in the collection are changing concurrently.
Error message
Multiple items in the collection are changing concurrently.
What it means
AutoUpdatingSortedObservableCollection subscribes to each item's PropertyChanging to preregister the changing item and its index for later reordering. If ItemPropertyChanging fires for a second item while ChangingItem still refers to a different item (no matching ItemPropertyChanged in between), the internal change-tracking invariant is broken and it throws.
Solutions
- Ensure every PropertyChanging is paired with exactly one PropertyChanged on the same object, with no interleaved changes to other items
- Fix item property setters that mutate other collection items while a change is in progress
- Wrap multi-item mutations so each item's change completes before the next starts
- Add a try/finally in setters so PropertyChanged fires even if intermediate code throws
Example fix
// before
public int Score
{
get => score;
set { score = value; neighbor.Score = value; } // cascades into another item mid-change
}
// after
public int Score
{
get => score;
set { SetProperty(ref score, value); } // cascade done from outside, sequentially
} Defensive patterns
Strategy: validation
Validate before calling
// Audit item setters: ensure no setter mutates another item of the same collection while raising PropertyChanging/PropertyChanged
Try / catch
try { collection.UpdateItems(...); } catch (InvalidOperationException ex) { logger.Error(ex, "interleaved item change"); } Prevention
- Keep property setters self-contained — no cascading mutations of sibling items
- Always pair PropertyChanging with PropertyChanged
- Use try/finally so Changed fires even if setter code throws
When it happens
Trigger: Nested property changes on two different items within one PropertyChanging/PropertyChanged cycle, e.g. an item's property setter mutating another item already in the collection; exceptions in property setters that prevent PropertyChanged from firing.
Common situations: Interdependent view-models where one object's property change cascades into another's; batch updates that mutate several items inside one change scope; buggy INotifyPropertyChanged implementations that raise Changed without Changing.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- PropertyChanged is invoked without PropertyChanging, or…
- The list must implements INotifyPropertyChanged
- AfterUpdate cannot be called out of the micro-thread…
- An element with the same key has already been added.
- An id is both marked as deleted and associated to a key of…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/08810cfbd72ca2d1.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation/Collections/AutoUpdatingSortedObservableCollection.cs:114
propertyNames.Add(name);
}
}
}
/// <inheritdoc/>
public override string ToString()
{
return $"{{AutoUpdatingSortedObservableCollection}} Count = {Count}";
}
protected virtual void ItemPropertyChanging(object? sender, PropertyChangingEventArgs e)
{
if (e.PropertyName is null || propertyNames?.Contains(e.PropertyName) == false)
return;
var item = (T?)sender;
if (ChangingItem is not null && !ReferenceEquals(ChangingItem, item))
throw new InvalidOperationException("Multiple items in the collection are changing concurrently.");
++changeCount;
ChangingItem = item;
ChangingIndex = GetIndex(item, false);
AddedItem = null;
}
protected virtual void ItemPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is null || propertyNames?.Contains(e.PropertyName) == false)
return;
var item = (T?)sender;
// An object has been added while a property of an existing object has been modified
if (ChangingItem is not null && AddedItem is not null)
throw new InvalidOperationException("PropertyChanged is invoked without PropertyChanging, or multiple items in the collection are changing concurrently.");View on GitHub (pinned to 96fad776d2)