MessageQueue.GetAllMessages Method
This page is specific to:.NET Framework Version:1.12.03.03.54.0
.NET Framework Class Library
MessageQueue.GetAllMessages Method

Returns all the messages that are in the queue.

Namespace: System.Messaging
Assembly: System.Messaging (in system.messaging.dll)

Syntax

'Usage

Dim instance As MessageQueue
Dim returnValue As Message()

returnValue = instance.GetAllMessages

'Declaration

Public Function GetAllMessages As Message()
public Message[] GetAllMessages ()

Return Value

An array of type Message that represents all the messages in the queue, in the same order as they appear in the Message Queuing queue.
Exceptions

Exception typeCondition

MessageQueueException

An error occurred when accessing a Message Queuing method.

Remarks

GetAllMessages returns a static snapshot of the messages in the queue, not dynamic links to those messages. Therefore, you cannot use the array to modify the messages in the queue. If you want real-time, dynamic interaction with the queue (such as the ability to delete messages), call the GetMessageEnumerator2 method, which returns a dynamic list of the messages in the queue.

Because GetAllMessages returns a copy of the messages in the queue at the time the method was called, the array does not reflect new messages that arrive in the queue or messages that are removed from the queue.

GetAllMessages retrieves only those properties not filtered out by the MessageReadPropertyFilter property.

The following table shows whether this method is available in various Workgroup modes.

Workgroup mode

Available

Local computer

Yes

Local computer and direct format name

Yes

Remote computer

No

Remote computer and direct format name

Yes

Example

The following code example demonstrates the use of GetAllMessages.

We do not yet have a code sample for this language.
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Populate an array with copies of all the messages in the queue.
Message msgs[] = queue.GetAllMessages();
// Loop through the messages.
for (int iCtr = 0; iCtr < msgs.length; iCtr++) {
    Message msg = msgs[iCtr];
    // Display the label of each message.
    Console.WriteLine(msg.get_Label());
}

.NET Framework Security

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
Platforms

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Version Information

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0
See Also

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View