Assembly: System.ServiceModel (in system.servicemodel.dll)
IAsyncResult BeginTryReceive ( TimeSpan timeout, AsyncCallback callback, Object state )
function BeginTryReceive ( timeout : TimeSpan, callback : AsyncCallback, state : Object ) : IAsyncResult
The Timespan that specifies the interval of time to wait for a message to become available.
The AsyncCallback delegate that receives the notification of the asynchronous operation completion.
An object, specified by the application, that contains state information associated with the asynchronous operation.
Return ValueThe IAsyncResult that references the asynchronous receive operation.
Use the asynchronous BeginTryReceive method when you want the application processing to continue without waiting. Use the synchronous TryReceive method when it is acceptable for the current thread to be blocked while it replies to the request message or until the timeout interval is exceeded.
The operation is not complete until either a message becomes available in the channel or the timeout occurs.
If you are going to handle timeouts and not just re-throw or wrap the TimeoutException, then you should call BeginTryReceive instead of BeginReceive.
If you are not going to treat timeouts specially then just call BeginReceive, otherwise you lose error information.Notes to Implementers: The operation returns false from EndTryReceive if the specified timeout is exceeded.
The following code illustrates how to implement this method:
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.