Partager via


Reading Messages Synchronously (COM) (Windows Embedded CE 6.0)

1/6/2010

To read messages synchronously, you must open the queue with receive or peek access, then call the appropriate peek or receive method to read the message in the queue. This example shows how to retrieve the first message in the queue.

Note

You cannot read messages from remotes queue when performing a transaction or when operating offline.

When reading messages synchronously, execution is blocked until a message is available or the message time-out timer expires.

To read the first message synchronously

  1. Declare the objects needed to read a message.

    These examples use a MSMQQueueInfo, MSMQQueue, and MSMQMessage object.

  2. Open the queue with receive or peek access.

    The following example opens the queue with receive access. This allows you to peek or retrieve the messages in the queue.

  3. Call MSMQQueue.Receive to retrieve the message.

  4. Call MSMQQueue.Close to close the queue.

For a code example using C++ COM, see C++ COM Code Example: Reading Messages Synchronously.

See Also

Concepts

Reading Messages in a Queue (COM)
MSMQ COM Support
Using the COM Components
MSMQ Security

Other Resources

Message Queuing