public void ClearMsg(AppMsg appMsg)
{
if (msgQueue.Contains(appMsg) || stickyQueue.Contains(appMsg))
{
RemoveMessages(MESSAGE_DISPLAY, appMsg);
RemoveMessages(MESSAGE_ADD_VIEW, appMsg);
RemoveMessages(MESSAGE_REMOVE, appMsg);
Queue<AppMsg> save = new Queue<AppMsg>();
int count = msgQueue.Count;
for (int i = 0; i < count; i++)
{
AppMsg msg = msgQueue.Dequeue();
if (msg == appMsg)
{
continue;
}
save.Enqueue(msg);
}
msgQueue = save;
save = new Queue<AppMsg>();
count = stickyQueue.Count;
for (int i = 0; i < count; i++)
{
AppMsg msg = stickyQueue.Dequeue();
if (msg == appMsg)
{
continue;
}
save.Enqueue(msg);
}
stickyQueue = save;
}
}