IWbemServices::CancelAsyncCall method
The IWbemServices::CancelAsyncCall method cancels any currently pending asynchronous calls based on the IWbemObjectSink pointer, which was originally passed to the asynchronous method. The outstanding IWbemObjectSink pointer can be released prior to the call or after the call returns. The CancelAsyncCall method is not operational from within a sink and is not supported by method providers. This means only the client end of the call is canceled. The implementing provider is not notified that the call was canceled and runs to completion. You should consider this before canceling methods that take a long time to complete, such as the Defrag and Format methods in the Win32_Volume class.
Syntax
HRESULT CancelAsyncCall(
[in] IWbemObjectSink *pSink
);
Parameters
- pSink [in]
-
Pointer to the IWbemObjectSink implementation provided by the client to any of the asynchronous methods of IWbemServices.
Return value
This method returns an HRESULT that indicates the status of the method call. The following table lists the value contained within an HRESULT.
On failure, you can obtain available information from the COM function GetErrorInfo.
COM-specific error codes can also be returned if network problems cause you to lose the remote connection to Windows Management.
Note If SetStatus has not been called on the application's sink by the time WMI processes CancelAsyncCall, WMI calls SetStatus on that sink with WBEM_E_CALL_CANCELLED as the value for the hResult parameter.
Timing, and the nature of an asynchronous operation, can affect whether WMI is able to cancel the operation. Only lengthy queries are likely to be successfully canceled before they have completed. Faster operations, such as asynchronous deletions or modifications, typically complete before WMI can process a CancelAsyncCall call. So while CancelAsyncCall attempts to cancel the current operation, sometimes all that can be done is to release the IWbemObjectSink pointer.
Note It is possible to make numerous asynchronous calls using the same object sink. In this case, the CancelAsyncCall method cancels all asynchronous calls sharing this object sink. It is strongly recommended that you create one instance of an object sink for each outstanding asynchronous call.
| Return code | Description |
|---|---|
|
Unspecified error. |
|
Supplied interface in pSink did not correspond to a pending asynchronous request. |
|
Not enough memory to complete the operation. |
|
Windows Management service was stopped and restarted. A new call to ConnectServer is required. |
|
Failure of the remote procedure call (RPC) link between the current process and Windows Management. |
|
Call succeeded. |
Remarks
Because the call-back to the sink might not be returned at the same authentication level as the client requires, it is recommended that you use semisynchronous instead of asynchronous communication. For more information, see Calling a Method. Calling CancelAsyncCall from within an implementation of IWbemObjectSink::Indicate or IWbemObjectSink::SetStatus can interfere with the WMI state and is not recommended.
In the case of a method call such as ExecMethodAsync, only the client end of the call is canceled. The implementing provider is not notified that the call was canceled and runs to completion.
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/19/2012