Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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 codeDescription
WBEM_E_FAILED

Unspecified error.

WBEM_E_INVALID_PARAMETER

Supplied interface in pSink did not correspond to a pending asynchronous request.

WBEM_E_OUT_OF_MEMORY

Not enough memory to complete the operation.

WBEM_E_SHUTTING_DOWN

Windows Management service was stopped and restarted. A new call to ConnectServer is required.

WBEM_E_TRANSPORT_FAILURE

Failure of the remote procedure call (RPC) link between the current process and Windows Management.

WBEM_S_NO_ERROR

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 XP

Minimum supported server

Windows Server 2003

Header

Wbemcli.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

Fastprox.dll;
Esscli.dll;
Framedyn.dll;
Ntevt.dll;
Stdprov.dll;
Viewprov.dll;
Wbemcomn.dll;
Wbemcore.dll;
Wbemess.dll;
Wbemsvc.dll;
Wmipicmp.dll;
Wmidcprv.dll;
Wmipjobj.dll;
Wmiprvsd.dll

See also

IWbemObjectSink
IWbemServices

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.