You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
I am seeing very occasional 'enumeration is modified' exceptions when calling Messenger.Send(), as follows:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator.MoveNext()
at System.Linq.Enumerable.<TakeIterator>d__25`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at GalaSoft.MvvmLight.Messaging.Messenger.SendToTargetOrType[TMessage](TMessage message, Type messageTargetType, Object token) in C:\Users\lbugn\Documents\MVVMLight\GalaSoft.MvvmLight\GalaSoft.MvvmLight (PCL)\Messaging\Messenger.cs:line 671
at GalaSoft.MvvmLight.Messaging.Messenger.Send[TMessage](TMessage message) in C:\Users\lbugn\Documents\MVVMLight\GalaSoft.MvvmLight\GalaSoft.MvvmLight (PCL)\Messaging\Messenger.cs:line 296
Looking at the source code I note that there is a lock around this use of the _recipientsOfSubclassesAction dictionary:
lock (_recipientsOfSubclassesAction)
{
list = _recipientsOfSubclassesAction[type].Take(_recipientsOfSubclassesAction[type].Count()).ToList();
}
but not around this one:
// Clone to protect from people registering in a "receive message" method
// Correction Messaging BL0008.002
var listClone =
_recipientsOfSubclassesAction.Keys.Take(_recipientsOfSubclassesAction.Count()).ToList();
which seems to be the source of the error (line 671)
Should this be updated?
The text was updated successfully, but these errors were encountered:
I am seeing very occasional 'enumeration is modified' exceptions when calling
Messenger.Send()
, as follows:Looking at the source code I note that there is a lock around this use of the
_recipientsOfSubclassesAction
dictionary:but not around this one:
which seems to be the source of the error (line 671)
Should this be updated?
The text was updated successfully, but these errors were encountered: