This project has moved and is read-only. For the latest updates, please go here.


KeyNotFoundException in Messenger.SendToTargetOrType


In recent version, locks have been added to the Messenger class, which solved some issues I had in an older version, but I think you've missed one place where multi-threaded use of the Messenger runs into an error:

(starting around line 588): The lock should surround the ContainsKey check in the code below.

        if (_recipientsStrictAction != null)
            if (_recipientsStrictAction.ContainsKey(messageType))
                List<WeakActionAndToken> list = null;

                lock (_recipientsStrictAction)
                    list = _recipientsStrictAction[messageType].Take(_recipientsStrictAction[messageType].Count()).ToList();

                SendToList(message, list, messageTargetType, token);
Closed Oct 13, 2014 at 1:56 PM by lbugnion