c++windowswinapiwindows-updatewuapi

ISearchJob->Release() stucking


I'm using wuapi to find Windows Updates. I faced with the problem: pJob->Release(); stucking in the following code on some machines, but generally it works correct. What could be the reason of such behavior?

I have tried to change ISearchJob* to CComPtr and remove pJob->Release();, but issue isn't gone. In this case program stucks on the end of the function.

        ISearchResult* pWUResult = NULL;
        ISearchJob* pJob = NULL;
        VARIANT pVar = { 0 };
        ISCC completeCB;
        hr = pWUSearcher->BeginSearch( bstrCriteria, &completeCB, pVar, &pJob );

        if ( SUCCEEDED(hr) )
        {
            WaitForSingleObject( completeCB._Event, INFINITE );

            hr = pWUSearcher->EndSearch( pJob, &pWUResult );
            pJob->Release();
        }

Solution

  • As @JonathanPotter suggested in comments, using pJob->CleanUp() instead of pJob->Release() was resolved the issue.