Export (0) Print
Expand All

IReplyChannel.TryReceiveRequest Method

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

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

bool TryReceiveRequest(
	TimeSpan timeout,
	out RequestContext context
)

Parameters

timeout
Type: System.TimeSpan

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

context
Type: System.ServiceModel.Channels.RequestContext

The RequestContext received.

Return Value

Type: System.Boolean
true if a request message is received before the specified interval of time elapses; otherwise false.

Use TryReceiveRequest(TimeSpan, RequestContext) when it is acceptable for the current thread to be blocked while it waits for a request 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 BeginTryReceiveRequest(TimeSpan, AsyncCallback, Object) method.

Notes to Implementers

The operation returns false if the specified timeout is exceeded.

The following code illustrates how to implement this method:

public bool TryReceiveRequest(TimeSpan timeout, out RequestContext requestContext)
{
    bool result;

    while (true)
    {
        result = this.InnerChannel.TryReceiveRequest(timeout, out requestContext);
        if (!result || ProcessRequestContext(ref requestContext))
        {
            break;
        }
    }

    return result;
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft