MessageQueue.Receive Method (TimeSpan, Cursor, MessageQueueTransaction)
Receives the current message in the queue, using a specified cursor. If no message is available, this method waits until either a message is available, or the time-out expires.
Assembly: System.Messaging (in System.Messaging.dll)
public Message Receive( TimeSpan timeout, Cursor cursor, MessageQueueTransaction transaction )
- Type: System.TimeSpan
A TimeSpan that indicates the time to wait until a new message is available for inspection.
- Type: System.Messaging.Cursor
A Cursor that maintains a specific position in the message queue.
The cursor parameter is null.
The transaction parameter is null.
A message did not arrive in the queue before the time-out expired.
The queue is non-transactional.
An error occurred when accessing a Message Queuing method.
Use this overload to receive a message from a transactional queue using the internal transaction context defined by the transaction parameter, and return within a specified period of time if there are no messages in the queue.
Because this method is called on a transactional queue, the message that is received is returned to the queue if the transaction is aborted. The message is not permanently removed from the queue until the transaction is committed.
To read a message in a queue without removing it from the queue, use the Peek method. There is no transaction context associated with a message returned by a call to Peek. Because Peek does not remove any messages in the queue, there is nothing to roll back by a call to Abort.
Use a call to Receive when it is acceptable for the current thread to be blocked while it waits for a message to arrive in the queue. The thread is blocked for the given period of time, or indefinitely if you specified the value InfiniteTimeout for the timeout parameter. If the application processing should continue without waiting for a message, consider using the asynchronous method, BeginReceive.
The following table shows whether this method is available in various Workgroup modes.
Local computer and direct format name
Remote computer and direct format name
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.