Creates an enumerator object for the messages contained in the MessageQueue.
[Visual Basic] Public Function GetMessagesEnumerator() As MessagesEnumerator [C#] public MessagesEnumerator GetMessagesEnumerator(); [C++] public: MessagesEnumerator* GetMessagesEnumerator(); [JScript] public function GetMessagesEnumerator() : MessagesEnumerator;
The MessagesEnumerator holding the messages contained in the queue.
MessageQueue.GetMessagesEnumerator creates a dynamic list of the queues contained in Message Queuing. Messages associated with the enumerator can be removed from the queue.
The following example gets a dynamic list of messages in a queue. It assumes that you have a queue withthe path "myComputer\myQueue". It then writes the body of each message to the console.
[Visual Basic]
Private Sub GetDynamicMessages() 'Define an enumerator to hold the messages. Dim msgEnum As MessagesEnumerator 'Define a message. Dim msg As Message 'Define and instantiate a MessageQueue. Dim messageQueue1 As MessageQueue messageQueue1 = New MessageQueue("myComputer\myQueue") 'Get the messages in the queue. msgEnum = messageQueue1.GetMessagesEnumerator 'Display the message bodies. For Each msg In msgEnum console.WriteLine(msg.BodyStream) Next End Sub
MessageQueue Class | MessageQueue Members | System.Messaging Namespace