Please see my comment to the question.
Formally speaking, the answer would be: read the current
snapshot via
System.Messaging.MessageQueue.GetAllMessages
and see what's in there:
https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.getallmessages%28v=vs.110%29.aspx[
^].
Is it a solution? No! In fact, it would be a big abuse. In general case, it's not even reliable and hence won't be acceptable. Let's see. You may have more than one thread (in the same process, or in several different ones) reading from the same queue. You took a snapshot, started to read based on it, but get blocked, because some other thread removed all messages.
So, what to do? The keyword is "blocked". Just read the message unconditionally and get the current thread blocked at the call, until a message arrives and get read. Therefore, it should be a separate thread dedicated to this. Please see:
https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.receive%28v=vs.110%29.aspx[
^],
see also
https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.peek%28v=vs.110%29.aspx[
^].
The idea is: no checkup.
Offensive programming, not defensive. Just receive or peek, instead of asking if you can receive of peek, and, optionally, handle the event when you received. Alternative variant of the same thing is using asynchronous versions of these methods:
https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.beginreceive%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.beginpeek%28v=vs.110%29.aspx[
^].
The common point here is that you use push approach, not pull, you handle the event when you actually get the message, and perform some action, say, push it further, to the UI, or whatever else.
Are you getting the idea? I won't be surprised if it appears that your thinking should be changed, fixed. But this is unavoidable. See also:
http://en.wikipedia.org/wiki/Pull_technology[
^],
https://en.wikipedia.org/wiki/Push_technology[
^].
See also my past answer, quite far from your original question; but this is something to think about:
Application 'dashboard' for website accounts[
^].
And, more generally, perhaps you will need to embrace the idea of
relativistic programming:
https://en.wikipedia.org/wiki/Relativistic_programming[
^].
—SA