IInputChannel.TryReceive Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Tries to receive a message within a specified interval of time.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Parameters
- timeout
- Type: System.TimeSpan
The IAsyncResult returned by a call to one of the BeginReceive(AsyncCallback, Object) methods.
- message
- Type:
System.ServiceModel.Channels.Message
%
The Message received.
Return Value
Type: System.Booleantrue if a message is received before the timeout has been exceeded; otherwise false.
| Exception | Condition |
|---|---|
| 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.