Here is the code to enumerate the messages.
MessageQueue queue = // ... some local private queue
Cursor cursor = queue.CreateCursor();
Message msg = queue.Peek(timeout, cursor, PeekAction.Current);
while( msg != null )
{
// ... process
msg = queue.Peek(timeout, cursor, PeekAction.Next);
}
Suppose I have 100 HIGH priority messages and 10000 LOW priority messages in the queue.
So it would peek the messages in following order.
HIGH #1
HIGH #2
HIGH #3
...
HIGH #99
HIGH #100
LOW #101
LOW #102
...
LOW #10000
Now suppose the code starts to run, it first handled the 100 HIGH priority messages then starts to handles the low priority messages.
At some point it peeked up a LOW priority as below.
LOW #8243 <-- cursor is here now
LOW #8244
...
LOW #10000
Now a new HIGH priority message arrived in the queue.
My question is:
Will the HIGH priority message be peeked up immediately for the next call to queue.Peek(timeout, cursor, PeekAction.Current)
?