redundant unsubscribing should be fine
This commit is contained in:
parent
5dde912564
commit
21c7e4d050
@ -138,14 +138,22 @@ namespace franz
|
||||
_TelefranzConsumers<T>.wrappings[theAction] = wrapped;
|
||||
topicSubscribers[topic]++;
|
||||
}
|
||||
public void removeHandler<T>(Action<T> theAction) where T : silver_messages.message
|
||||
public bool removeHandler<T>(Action<T> theAction) where T : silver_messages.message
|
||||
{
|
||||
topicConsumers[typeof(T).ToString()].MessageReceived -= _TelefranzConsumers<T>.wrappings[theAction];
|
||||
_TelefranzConsumers<T>.wrappings.Remove(theAction);
|
||||
topicSubscribers[typeof(T).ToString()]--;
|
||||
if (topicSubscribers[typeof(T).ToString()] == 0)
|
||||
if (_TelefranzConsumers<T>.wrappings.ContainsKey(theAction))
|
||||
{
|
||||
topicConsumers[typeof(T).ToString()].StopConsume();
|
||||
_TelefranzConsumers<T>.wrappings.Remove(theAction);
|
||||
topicSubscribers[typeof(T).ToString()]--;
|
||||
if (topicSubscribers[typeof(T).ToString()] == 0)
|
||||
{
|
||||
topicConsumers[typeof(T).ToString()].StopConsume();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user