diff --git a/src/Orleans.Core/Utils/ObserverManager.cs b/src/Orleans.Core/Utils/ObserverManager.cs index 238c38e393..71d023e6fd 100644 --- a/src/Orleans.Core/Utils/ObserverManager.cs +++ b/src/Orleans.Core/Utils/ObserverManager.cs @@ -153,7 +153,7 @@ public async Task Notify(Func notification, Func); - foreach (var observer in _observers) + foreach (var observer in _observers.ToList()) { if (observer.Value.LastSeen + ExpirationDuration < now) { @@ -208,7 +208,7 @@ public void Notify(Action notification, Func predica { var now = GetDateTime(); var defunct = default(List); - foreach (var observer in _observers) + foreach (var observer in _observers.ToList()) { if (observer.Value.LastSeen + ExpirationDuration < now) { @@ -257,7 +257,7 @@ public void ClearExpired() { var now = GetDateTime(); var defunct = default(List); - foreach (var observer in _observers) + foreach (var observer in _observers.ToList()) { if (observer.Value.LastSeen + ExpirationDuration < now) {