Peek(TimeSpan,Cursor,PeekAction) Method
Returns without removing (peeks) the current or next message in the queue, using the specified cursor. The Peek method is synchronous, so it blocks the current thread until a message becomes available or the specified time-out occurs.
Syntax
'Declaration Public Overloads Function Peek( _ ByVal timeout As TimeSpan, _ ByVal cursor As Cursor, _ ByVal action As PeekAction _ ) As Message
'Usage Dim instance As MessageQueue Dim timeout As TimeSpan Dim cursor As Cursor Dim action As PeekAction Dim value As Message value = instance.Peek(timeout, cursor, action)
Parameters
- timeout
- A System.TimeSpan that indicates the maximum time to wait for the queue to contain a message.
- cursor
- A Cursor that maintains a specific position in the message queue.
- action
- One of the PeekAction values. Indicates whether to peek at the current message in the queue, or the next message.
Return Value
A Message that represents a message in the queue.
Exceptions
Exception | Description |
---|---|
System.ArgumentOutOfRangeException | A value other than PeekAction.Current or PeekAction.Next was specified for the action parameter. |
System.ArgumentNullException | The cursor parameter is null. |
System.ArgumentException | The value specified for the timeout parameter is not valid. Possibly timeout is less than System.TimeSpan.Zero or greater than InfiniteTimeout. |
MessageQueueException | An error occurred when accessing a Message Queuing method. |
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also