Is there any way to check if a public MSMQ is empty? For a private MSMQ it's easy:
private bool IsQueueEmpty(string path)
{
bool isQueueEmpty = false;
var myQueue = new MessageQueue(path);
try
{
myQueue.Peek(new TimeSpan(0));
isQueueEmpty = false;
}
catch (MessageQueueException e)
{
if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
{
isQueueEmpty = true;
}
}
return isQueueEmpty;
}
How would I do the same check for a public MSMQ? If I try to check a public MSMQ with the code above it gives me an error on the Peak:
System.ArgumentOutOfRangeException: Length cannot be less than zero.