MessageReceiver.TryReceive Method (TimeSpan, BrokeredMessage%)

Tries to receive a brokered message.

Namespace:  Microsoft.ServiceBus.Messaging
Assembly:  Microsoft.ServiceBus.Messaging (in Microsoft.ServiceBus.Messaging.dll)

Syntax

'Declaration
Public Function TryReceive ( _
    serverWaitTime As TimeSpan, _
    <OutAttribute> ByRef message As BrokeredMessage _
) As Boolean
'Usage
Dim instance As MessageReceiver
Dim serverWaitTime As TimeSpan
Dim message As BrokeredMessage
Dim returnValue As Boolean

returnValue = instance.TryReceive(serverWaitTime, _
    message)
public bool TryReceive(
    TimeSpan serverWaitTime,
    out BrokeredMessage message
)
public:
bool TryReceive(
    TimeSpan serverWaitTime, 
    [OutAttribute] BrokeredMessage^% message
)
member TryReceive : 
        serverWaitTime:TimeSpan * 
        message:BrokeredMessage byref -> bool 
public function TryReceive(
    serverWaitTime : TimeSpan, 
    message : BrokeredMessage
) : boolean

Parameters

  • serverWaitTime
    Type: System.TimeSpan
    The server wait time before the operation times out.

Return Value

Type: System.Boolean
true if the attempt succeeds, false if it fails.

Remarks

This method can have the following outcomes:

  • return true with message != null: a message was received

  • return false with message == null: a timeout has occurred

  • return true with message == null: a call was successful but there are no more messages to receive

See Also

Reference

MessageReceiver Class

TryReceive Overload

Microsoft.ServiceBus.Messaging Namespace