Export (0) Print
Expand All

IInputChannel.TryReceive Method

Tries to receive a message within a specified interval of time.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

bool TryReceive(
	TimeSpan timeout,
	out Message message
)

Parameters

timeout
Type: System.TimeSpan
The IAsyncResult returned by a call to one of the BeginReceive methods.
message
Type: System.ServiceModel.Channels.Message%
The Message received.

Return Value

Type: System.Boolean
true if a message is received before the timeout has been exceeded; otherwise false.

ExceptionCondition
TimeoutException

The specified timeout is exceeded before the operation is completed.

ArgumentOutOfRangeException

The timeout specified is less than zero.

If you are going to handle timeouts and not just re-throw or wrap the TimeoutException, then you should call TryReceive(TimeSpan, Message) instead of Receive.

If you are not going to treat timeouts specially then call Receive, otherwise you lose error information.

The following code shows how to implement this method.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft