IReplyChannel.TryReceiveRequest(TimeSpan, RequestContext) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a value that indicates whether a request is received before a specified interval of time elapses.
public:
bool TryReceiveRequest(TimeSpan timeout, [Runtime::InteropServices::Out] System::ServiceModel::Channels::RequestContext ^ % context);
public bool TryReceiveRequest (TimeSpan timeout, out System.ServiceModel.Channels.RequestContext context);
abstract member TryReceiveRequest : TimeSpan * RequestContext -> bool
Public Function TryReceiveRequest (timeout As TimeSpan, ByRef context As RequestContext) As Boolean
Parameters
- timeout
- TimeSpan
The TimeSpan that specifies how long the receive of a request operation has to complete before timing out and returning false
.
- context
- RequestContext
The RequestContext received.
Returns
true
if a request message is received before the specified interval of time elapses; otherwise false
.
Examples
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;
}
Remarks
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.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기