public void AddMail(ulong mailGuid, DateTime expiryDate) { lock (m_Lock) { MailState state = null; if (!m_WholeMailStates.ContainsKey(mailGuid)) { state = new MailState(); state.MailGuid = mailGuid; state.ExpiryDate = expiryDate; state.IsRead = false; state.IsReceived = false; state.IsDeleted = false; m_WholeMailStates.Add(mailGuid, state); } } }
public void RemoveExpiredMails() { lock (m_Lock) { DateTime nowDate = DateTime.Now; foreach (KeyValuePair <ulong, MailState> pair in m_WholeMailStates) { MailState state = pair.Value; if (state.ExpiryDate < nowDate) { m_ExpiredMails.Add(state.MailGuid); } } foreach (ulong guid in m_ExpiredMails) { m_WholeMailStates.Remove(guid); } m_ExpiredMails.Clear(); } }