Share via


Purging a Queue Synchronously (COM)

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

To purge the messages from a queue, you must call MSMQQueue.Receive for each message in the queue.

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

To purge a queue synchronously

  1. Declare the objects needed to retrieve a message.

    This example declares an MSMQQueueInfo, MSMQQueue, and MSMQMessage object.

  2. Call MSMQQueueInfo.Open and open the queue with receive access.

  3. Call MSMQQueue.Receive to retrieve each message in the queue.

    The following example uses MSMQQueue.Receive to retrieve the first message in the queue.

  4. Call MSMQQueue.Close to close the queue.

For a code example using C++ COM, see C++ COM Code Example: Purging a Queue Synchronously.

See Also

Concepts

MSMQ COM Support
Using the COM Components
MSMQ Security

Other Resources

Message Queuing