System.Messaging Reference (Document! X Sample)
System.Messaging Namespace / MessageQueue Class / Peek Method / Peek(TimeSpan) Method
A System.TimeSpan that indicates the maximum time to wait for the queue to contain a message.



In This Topic
    Peek(TimeSpan) Method
    In This Topic
    Returns without removing (peeks) the first message in the queue referenced by this MessageQueue. 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 _
    ) As Message
    'Usage
     
    
    Dim instance As MessageQueue
    Dim timeout As TimeSpan
    Dim value As Message
     
    value = instance.Peek(timeout)
    public Message Peek( 
       TimeSpan timeout
    )
    public:
    Message^ Peek( 
       TimeSpan timeout
    ) 

    Parameters

    timeout
    A System.TimeSpan that indicates the maximum time to wait for the queue to contain a message.

    Return Value

    The Message that represents the first message in the queue.
    Exceptions
    ExceptionDescription
    The value specified for the timeout parameter is not valid, possibly timeout is less than System.TimeSpan.Zero or greater than InfiniteTimeout.
    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