MessageEnumerator::RemoveCurrent Method (TimeSpan)
Removes the current message from the queue and returns the message to the calling application. If there is a message to remove, the method returns it immediately. Otherwise, the method waits the specified timeout for a new message to arrive.
Assembly: System.Messaging (in System.Messaging.dll)
Parameters
- timeout
-
Type:
System::TimeSpan
The interval of time to wait for a message to arrive in the queue.
Return Value
Type: System.Messaging::Message^A Message that references the first message available in the queue.
| Exception | Condition |
|---|---|
| ArgumentException | The value specified for the timeout parameter is invalid. |
| MessageQueueException | The timeout has expired. |
RemoveCurrent removes and returns the message at the cursor's current location. If the cursor is at the end of the queue, this overload of the method waits until a message is available or the interval specified by the timeout parameter has expired.
If you are using queue journaling, removing the message causes a copy to be kept in the journal queue, just as the MessageQueue class's Receive method does.
When you remove the current message, the cursor is moved to the next message. You do not have to call MoveNext after calling RemoveCurrent.
If you call this overload on a transactional queue, Message Queuing creates a single internal transaction.
Available since 1.1