NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MessageQueue.GetMessagesEnumerator

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;

Return Value

The MessagesEnumerator holding the messages contained in the queue.

Remarks

MessageQueue.GetMessagesEnumerator creates a dynamic list of the queues contained in Message Queuing. Messages associated with the enumerator can be removed from the queue.

Example [Visual Basic]

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

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace