/// <summary> /// Indicates that an inbox is no longer in use /// </summary> /// <param name="user">The user</param> public void FinishedUsingInbox(object user) { if (user == null) throw new NullArgumentException("user"); lock (_inboxFactoringLock) { try { IInbox inbox = _userInboxes[user]; _userInboxes.Remove(user); ulong inboxUsers = _inboxUsers[inbox] - 1; if (inboxUsers == 0) { string replyAddress = inbox.InboxServerConfiguration.ReplyAddress; if (inbox.InboxState == InboxState.Listening) inbox.Close(); _inboxes.Remove(replyAddress); _inboxUsers.Remove(inbox); } _inboxUsers[inbox] = inboxUsers; } catch (Exception ex) { throw new FailedToStopUsingInboxException(user, ex); } } }