Export (0) Print
Expand All

MessageQueue.Peek Method (TimeSpan, Cursor, PeekAction)

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.

Namespace: System.Messaging
Assembly: System.Messaging (in system.messaging.dll)

public Message Peek (
	TimeSpan timeout,
	Cursor cursor,
	PeekAction action
)
public Message Peek (
	TimeSpan timeout, 
	Cursor cursor, 
	PeekAction action
)
public function Peek (
	timeout : TimeSpan, 
	cursor : Cursor, 
	action : PeekAction
) : Message
Not applicable.

Parameters

timeout

A 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.

Exception typeCondition

ArgumentOutOfRangeException

A value other than PeekAction.Current or PeekAction.Next was specified for the action parameter.

ArgumentNullException

The cursor parameter is a null reference (Nothing in Visual Basic).

ArgumentException

The value specified for the timeout parameter is not valid. Possibly timeout is less than TimeSpan.Zero or greater than MessageQueue.InfiniteTimeout.

MessageQueueException

An error occurred when accessing a Message Queuing method.

Use this overload to peek a queue, or to wait a specified period of time until a message exists in the queue. The method returns immediately if a message already exists in the queue.

The Peek method reads, but does not remove, a message from the queue. The Receive method, on the other hand, both reads and removes a message from the queue.

Use Peek 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 up to the specified period of time, or indefinitely if you indicated InfiniteTimeout. If you need the application processing to continue without waiting, use the asynchronous BeginPeek method.

The following table shows whether this method is available in various Workgroup modes.

Workgroup mode

Available

Local computer

Yes

Local computer and direct format name

Yes

Remote computer

No

Remote computer and direct format name

Yes

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft