Edit

Share via


IReplyChannel.WaitForRequest(TimeSpan) Method

Definition

Returns a value that indicates whether a request message is received before a specified interval of time elapses.

public:
 bool WaitForRequest(TimeSpan timeout);
public bool WaitForRequest (TimeSpan timeout);
abstract member WaitForRequest : TimeSpan -> bool
Public Function WaitForRequest (timeout As TimeSpan) As Boolean

Parameters

timeout
TimeSpan

The TimeSpan that specifies how long a request operation has to complete before timing out and returning false.

Returns

true if a request is received before the specified interval of time elapses; otherwise false.

Examples

The following code illustrates how to implement this method:

public bool WaitForRequest(TimeSpan timeout)
{
    return this.InnerChannel.WaitForRequest(timeout);
}

Remarks

Calling WaitForRequest(TimeSpan) does not result in a request message being received or processed in any way.

The BeginWaitForRequest(TimeSpan, AsyncCallback, Object) method exists primarily for transacted scenarios where the user wants to receive the message using a transaction. When using just ReceiveRequest normally for this, the user must create the transaction, and then call ReceiveRequest and hope the message arrives before the transaction times out, which may not be possible.

Instead, the user can call WaitForRequest(TimeSpan) and specify the time out (even infinite), then when a message arrives they can open the transaction, call ReceiveRequest and be confident that they can get the message back before the transaction expires.

Use WaitForRequest(TimeSpan) when it is acceptable for the current thread to be blocked while it waits for a message to arrive in the queue. The thread is blocked up to the specified timeout. If you need the application processing to continue without waiting, use the asynchronous BeginWaitForRequest(TimeSpan, AsyncCallback, Object) method.

Notes to Implementers

The operation returns false if the specified timeout is exceeded.

Applies to