Receives the first message available in the queue referenced by the MessageQueue. Waits the specified interval for the message to be removed.
[Visual Basic] Overloads Public Function BeginReceive( _ ByVal timeout As TimeSpan _ ) As IAsyncResult [C#] public IAsyncResult BeginReceive( TimeSpan timeout ); [C++] public: IAsyncResult* BeginReceive( TimeSpan timeout ); [JScript] public function BeginReceive( timeout : TimeSpan ) : IAsyncResult;
The IAsyncResult that identifies the asynchronous request posted.
Exception Type | Condition |
---|---|
ArgumentException | The value specified for the timeout parameter is invalid. It may represent a negative number. |
BeginReceive is used in asynchronous processing to raise the System.Messaging.MessageQueue.MessageQueue.ReceiveCompleted event when a message is removed from the queue or the timeout has expired.
Because BeginReceive is asynchronous, you can use this method to peek the queue without blocking the current thread of execution. To peek the queue synchronously, use the Receive method.
Set the timeout to zero to determine whether there is a message in the queue without receiving the message.
MessageQueue Class | MessageQueue Members | System.Messaging Namespace | MessageQueue.BeginReceive Overload List | EndReceive | BeginPeek | Receive | Peek