1

Closed

KeyNotFoundException in Messenger.SendToTargetOrType

description

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 12:56 PM by lbugnion

comments