RE: WinMgmt File Lock and CancelAsyncCall Questions

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Gary,
There's still a few points you've made that aren't coming through very
clearly:

"So if attempt to cancel async call, WMI should know the operation cancelled
by client and call release() on the sink object. ( why need to call
CancelAsyncCall() from client during the operation period. Ex.
NotificationQuery)"

Ok, I understand the point about once I've called CancelAsyncCall that WMI
knows the operation has been cancelled by the client, and therefore, COM/WMI
calls Release() on the sink object (after, I assume it has called SetStatus()
to indicate failure). What I don't understand is this part: " why need to
call CancelAsyncCall() from client during the operation period. Ex.
NotificationQuery"

"in your case, the sink is cancelled by client, so the SetStatus() will not
be called by WMI for cancellation signal (no need)"

That's a strange point that flies in the face of empirical evidence because
every time I cancel a WMI call via CancelAsyncCall() (that hasn't already
completed obviously), my sink's SetStatus() method is called with a flag of
WBEM_STATUS_COMPLETE and an HRESULT of WBEM_E_CALL_CANCELLED (0x80041032).
Are you sure about what you stated?

"Once async operation cancelled, you need to release the sink directly.(and
if still waiting for sink status, your service is block by itself, not
blocked by WMI)"

As soon as I call CancelAsyncCall(), I call the sink's Release() method. As
regards my service being blocked, my service has never been blocked. What
has happened is that my service exits normally (there is *NO* service process
running anymore), yet I cannot delete or replace the binary corresponding to
the service on disk because the WinMgmt service has somehow locked the file.
*ONLY* when I restart the WinMgmt service am I able to delete or replace the
file on disk. Again, there is *NO* instance of the executable running.

Thanks,

Matt

""Gary Chang[MSFT]"" wrote:

> Hi Matt,
>
> I am afraid my previous reply did not explain the scenario clear, so I got
> some more detailed explaination from our WMI specialist:
>
> A com object is managed by COM server via the refcount of the object (when
> ref count reach to 0, it will be deleted from memory by com) , so when a
> sink pass via WMI async calls, WMI (all com client|server app) will
> addref() during the operation, then end to Release() .
>
> So if attempt to cancel async call, WMI should know the operation cancelled
> by client and call release() on the sink object. ( why need to call
> CancelAsyncCall() from client during the operation period. Ex.
> NotificationQuery)
>
> And the Async calls totally control by client side, and SetStatus() is
> called by WMI server when
>
> 1. operation done
> 2. operation provide In-process status from provider (most of provide
> don't provide this implementation).
> 3. operation cancelled by WMI service
>
> in your case, the sink is cancelled by client, so the SetStatus() will not
> be called by WMI for cancellation signal (no need)
>
>
> By the way, are you checking the sink status for cancellation via
> SetStatus()? Once async operation cancelled, you need to release the sink
> directly.(and if still waiting for sink status, your service is block by
> itself, not blocked by WMI)
>
>
> Wish it helps!
>
> Best regards,
>
> Gary Chang
> Microsoft Community Support
> --------------------
> Get Secure! ¡§C www.microsoft.com/security
> Register to Access MSDN Managed Newsgroups!
> http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
> &SD=msdn
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
.



Relevant Pages

  • RE: WinMgmt File Lock and CancelAsyncCall Questions
    ... >The CancelAsyncCalljust notifies the cancel sign to WMI from client ... 'just notifies the cancel sign to WMI'? ... you saying that when I call CancelAsyncCall(), that WMI sends a message to ... > sink in your process. ...
    (microsoft.public.win32.programmer.wmi)
  • RE: WinMgmt File Lock and CancelAsyncCall Questions
    ... In regards to your answer regarding CancelAsyncCall, ... irrespective of whether I am currently connected to a local machine or a ... what I mean is that WMI has locked ... > method works, according to the MSDN doc, typically CancelAsyncCall call ...
    (microsoft.public.win32.programmer.wmi)
  • RE: WinMgmt File Lock and CancelAsyncCall Questions
    ... what I mean is that WMI has locked ... it execute image in the explorer. ... method works, according to the MSDN doc, typically CancelAsyncCall call ... attempts to cancel the current asynchronous operation by releasing the ...
    (microsoft.public.win32.programmer.wmi)
  • RE: WinMgmt File Lock and CancelAsyncCall Questions
    ... >connected to a local machine or a remote machine, ... The CancelAsyncCall() just notifies the cancel sign to WMI from client ... (release the ref count of the sink in server side), ...
    (microsoft.public.win32.programmer.wmi)