I'm currently doing it like this:
MessageQueue queue = new MessageQueue(".\Private$\myqueue");
MessageEnumerator messageEnumerator = queue.GetMessageEnumerator2();
int i = 0;
while (messageEnumerator.MoveNext())
{
i++;
}
return i;
But for obvious reasons, it just feels wrong - I shouldn't have to iterate through every message just to get a count, should I?
Is there a better way?