public MessageDispatch[] RemoveAll()
{
MessageDispatch[] result;
lock(mutex)
{
result = new MessageDispatch[this.size];
int copyPos = 0;
for(int i = MAX_PRIORITY - 1; i >= 0; i--)
{
LinkedList<MessageDispatch> list = channels[i];
list.CopyTo(result, copyPos);
copyPos += list.Count;
size -= list.Count;
list.Clear();
}
}
return result;
}