On Fri, 30 Sep 2005 12:57:17 -0500, tiger wrote:
Quote:
Hi,
I have a question on MS Message queuing.
I would like to check a message queuing to see if there is a message in the
queue. That is if the queue is empty, I would like to send a note to a
textbox.
Thanks
Tiger |
Chackout MessageQueue.Peek() method. You would need to call the Peek method
with a zero timeout within a try block and have a catch block for catching
MessageQueueException. Within this check for
MessageQueueErrorCode.IOTimeout error.
Something like
using System.Messaging;
MessageQueue somequeue = new Messageque(".\\somequeue");
try
{
someque.Peek(new TimeSpan(0));
//if it reaches here queue is not empty
}
catch (MessageQueueException ex)
{
if (ex.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
{
//queue is empty
}
}
HTH,
Ayyappan Nair