MessageReceiver.TryReceive Method (TimeSpan, BrokeredMessage%)

Tries to receive a brokered message.

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


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

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


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


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


MessageReceiver Class

TryReceive Overload

Microsoft.ServiceBus.Messaging Namespace