NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MessageQueue.BeginPeek (TimeSpan, Object)

Returns without removing (peeks) the first message available in the queue referenced by the MessageQueue. Waits the specified interval for a new message to become available and uses the specified object to retrieve the result.

[Visual Basic]
Overloads Public Function BeginPeek( _
   ByVal timeout As TimeSpan, _
   ByVal stateObject As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginPeek(
   TimeSpan timeout,
   object stateObject
);
[C++]
public: IAsyncResult* BeginPeek(
   TimeSpan timeout,
   Object* stateObject
);
[JScript]
public function BeginPeek(
   timeout : TimeSpan,
   stateObject : Object
) : IAsyncResult;

Parameters

timeout
The interval of time, in milliseconds, to wait for a message to become available.
stateObject
A state object to be marshaled to the thread from which the asynchronous operation result is to be retrieved.

Return Value

The IAsyncResult that identifies the asynchronous request posted.

Exceptions

Exception Type Condition
ArgumentException The value specified for the timeout parameter is invalid. It may represent a negative number.

Remarks

The state object is used to handle passing information across threads. In an asynchronous scenario, if a thread is started but the callback is on a different thread, the state object is marshaled and passed back along with information from the event.

BeginPeek is used in asynchronous processing to notify the AsyncCallback delegate when a message is available or the specified timeout has expired.

Because BeginPeek 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 Peek method.

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | MessageQueue.BeginPeek Overload List | EndPeek | BeginReceive | Peek | Receive