แก้ไข

แชร์ผ่าน


IReplyChannel.BeginTryReceiveRequest(TimeSpan, AsyncCallback, Object) Method

Definition

Begins an asynchronous operation to receive a request message that has a specified time out and state object associated with it.

public:
 IAsyncResult ^ BeginTryReceiveRequest(TimeSpan timeout, AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state);
abstract member BeginTryReceiveRequest : TimeSpan * AsyncCallback * obj -> IAsyncResult
Public Function BeginTryReceiveRequest (timeout As TimeSpan, callback As AsyncCallback, state As Object) As IAsyncResult

Parameters

timeout
TimeSpan

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

callback
AsyncCallback

The AsyncCallback delegate that receives the notification of the asynchronous receive that a request operation completes.

state
Object

An object, specified by the application, that contains state information associated with the asynchronous receive of a request operation.

Returns

The IAsyncResult that references the asynchronous receive request operation.

Examples

The following code illustrates how to implement this method:

public IAsyncResult BeginTryReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state)
{
    TryReceiveRequestAsyncResult result = new TryReceiveRequestAsyncResult(this, timeout, callback, state);
    result.Begin();
    return result;
}

Remarks

Use the asynchronous BeginTryReceiveRequest(TimeSpan, AsyncCallback, Object) method when you need the application processing to continue without waiting. Use one of the synchronous TryReceiveRequest(TimeSpan, RequestContext) methods 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.

This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either a message becomes available in the channel or the time out occurs.

Notes to Implementers

The operation returns false if the specified timeout is exceeded.

Applies to