IReplyChannel.TryReceiveRequest(TimeSpan, RequestContext) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した時間間隔が経過する前に要求を受信するかどうかを示す値を返します。
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
パラメーター
- context
- RequestContext
受信した RequestContext 。
返品
true 指定された時間間隔が経過する前に要求メッセージを受信した場合。それ以外の場合は false。
例
次のコードは、このメソッドを実装する方法を示しています。
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;
}
注釈
TryReceiveRequest(TimeSpan, RequestContext)は、要求メッセージがキューに到着するのを待機している間に、現在のスレッドがブロックされるのを許容できる場合に使用します。 スレッドは、指定した timeoutまでブロックされます。 待機せずにアプリケーション処理を続行する必要がある場合は、非同期の BeginTryReceiveRequest(TimeSpan, AsyncCallback, Object) メソッドを使用します。
注意 (実装者)
指定したfalseを超えた場合、操作はtimeoutを返します。