<div class="content"><p> </p><p>The <b>R_CancelReceive</b> method cancels a pending call to
the R_StartReceive (Opnum 7) (section <span><a href="1bd20827-f774-4279-ae8d-4898d6faf6e9" data-linktype="relative-path">3.1.4.7)</a></span> method or
the R_StartTransactionalReceive (Opnum 13) (section <span><a href="c5296e0c-9e12-4fe8-a25d-56924982ac3e" data-linktype="relative-path">3.1.4.13)</a></span>
method. Each of those methods takes a time-out parameter that can cause the
server to not return a response until a <span><a href="b23ea276-dfad-4083-bc48-d0f8a40255fd#gt_85c78cf0-1fb6-4e5d-85f5-a2e9f58a6b9e" data-linktype="relative-path">message</a></span> becomes
available or the time-out expires. The <b>R_CancelReceive</b> method provides a
way for the client to cancel a blocked request.</p><dl>
<dd>
<div><pre> HRESULT R_CancelReceive(
   [in] handle_t hBind,
   [in] QUEUE_CONTEXT_HANDLE_NOSERIALIZE phContext,
   [in] DWORD dwRequestId
 );
</pre></div>
</dd></dl><p><b>hBind: </b>MUST be an <span><a href="b23ea276-dfad-4083-bc48-d0f8a40255fd#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a></span> binding handle
parameter as specified in <span><a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a></span>
section <span><a href="../ms-rpce/a01f5886-c485-4bcf-bb23-e0d755510ab7" data-linktype="relative-path">2</a></span>.</p><p><b>phContext: </b>MUST be set by the client to the <span><a href="3e818e81-b12a-4ccd-9606-f434c346a3e9" data-linktype="relative-path">QUEUE_CONTEXT_HANDLE_NOSERIALIZE (section 2.2.4.1)</a></span>
handle used in the corresponding call to the <b>R_StartReceive</b> method that
is to be canceled. The handle MUST have been returned by the server in the <i>pphQueue</i>
output parameter of a prior call to the R_OpenQueue (Opnum
2) (section <span><a href="b4b3001c-f2ff-4a17-9830-7b21af371dc4" data-linktype="relative-path">3.1.4.2)</a></span> method and
MUST NOT have been previously closed through a call to the R_CloseQueue (Opnum
3) (section <span><a href="e480114a-587f-4110-b03b-7a6188cca307" data-linktype="relative-path">3.1.4.3)</a></span> method.
This value MUST NOT be NULL.</p><p><b>dwRequestId: </b>MUST be set by the client to the
same value as the <i>dwRequestId</i> parameter in the corresponding call to the
<b>R_StartReceive</b> method or the <b>R_StartTransactionalReceive</b> method.
This parameter acts as an identifier to correlate an <b>R_CancelReceive</b>
method call to an <b>R_StartReceive</b> or an <b>R_StartTransactionalReceive</b>
method call.</p><p><b>Return Values: </b>On success, this method MUST return
MQ_OK (0x00000000).</p><p>If an error occurs, the server MUST return a failure <b>HRESULT</b>,
and the client MUST treat all failure <b>HRESULTs</b> identically.</p><p>Exceptions Thrown:</p><p>No exceptions are thrown except those thrown by the
underlying RPC protocol, as specified in [MS-RPCE].</p><p>When processing this call, the server MUST:</p><ul><li><p><span><span> 
</span></span>Find the corresponding <b>OpenQueueDescriptor</b> ADM element
instance by comparing the <i>phContext</i> parameter with the <b>Handle</b> ADM
attribute for all <b>OpenQueueDescriptor</b> ADM element instances maintained
by the local <b>QueueManager</b> ADM element instance.</p>
</li><li><p><span><span> 
</span></span>If not found, return a failure <b>HRESULT</b>, and perform no
further actions; otherwise, assign the found <b>OpenQueueDescriptor</b> ADM
element instance to the local variable <i>queueDesc</i>.</p>
</li><li><p><span><span> 
</span></span>Generate a <span><a href="../ms-mqdmpr/59e640f6-ce75-4c91-92d5-433038224cd4" data-linktype="relative-path">Cancel
Waiting Message Read Request</a></span> (<span><a href="../ms-mqdmpr/5eafe0a6-a22f-436b-a0d9-4cbc25c52b47" data-linktype="relative-path">[MS-MQDMPR]</a></span>
section 3.1.7.1.17) event with the following inputs: </p>
<ul><li><p><span><span>  </span></span><i>iQueue</i>
:= <i>queueDesc</i>.<b>QueueReference</b></p>
</li><li><p><span><span>  </span></span><i>iTag</i>
:= <i>dwRequestId</i></p>
</li></ul></li><li><p><span><span> 
</span></span>If the Cancel Waiting Message Read Request event returns an
error, return a failure <b>HRESULT</b>, and perform no further actions.</p>
</li><li><p><span><span> 
</span></span>Remove the <span><a href="d068bd5b-b930-404f-a147-05b27a6a82a0" data-linktype="relative-path">PendingRequestEntry (section 3.1.1.2)</a></span>
ADM element instance referenced by the {<i>phContext</i>, <i>dwRequestId</i>}
key pair from the <span><a href="9712f072-8179-43ba-861c-d9c50ab0df4f" data-linktype="relative-path">PendingRequestTable (section 3.1.1.3)</a></span>
ADM element.</p>
</li><li><p><span><span> 
</span></span>Respond to the pending <b>R_StartReceive</b> or <b>R_StartTransactionalReceive</b>
method request with MQ_ERROR_OPERATION_CANCELLED (0xC00E0008).</p>
</li></ul></div>