You are writing an application that provides a graphical administrative interface to a message queue that displays information about the messages.
The GUI is updated in the AdminFunction function.
You need to ensure that the GUI is updated without unnecessary delay, and that processed messages contain the most recent message contents.
What should you do?
A.
Read the messages from the message queue and update the GUI by using the following code segment.
MessageQueue queue = new MessageQueue(queueName, QueueAccessMode.Peek);
Cursor cursor = queue.CreateCursor();
Message m = queue.Peek();
while (m != null)
{
AdminFunction(m);
m = queue.Peek();
}
B.
Read the messages from the message queue and update the GUI by using the following code segment.
MessageQueue queue = new MessageQueue(queueName, QueueAccessMode.Peek);
Message[] messages = queue.GetAllMessages();
for (int i = 0; i < messages.Length; i++)
{
AdminFunction(messages[i]);
}
C.
Read the messages from the message queue and update the GUI by using the following code segment.
MessageQueue queue = new MessageQueue(queueName, QueueAccessMode.Peek);
Cursor queueCursor = queue.CreateCursor();
Message m = queue.Peek(timeout, queueCursor, PeekAction.Current);
while (m != null)
{
AdminFunction(m);
m = queue.Peek(timeout, queueCursor, PeekAction.Next);
}
D.
Read the messages from the message queue and update the GUI by using the following code segment.
MessageQueue queue = new MessageQueue(queueName, QueueAccessMode.Peek);
MessageEnumerator messages = queue.GetMessageEnumerator2();
while (messages.MoveNext())
{
AdminFunction(messages.current);
}