Figure 2   Asynchronous Implementation


 HRESULT CallIt(IUnknown *pUnk, long * pn) {
 // ask for ICallFactory
   CComPtr<ICallFactory> pcf = 0;
   pUnk->QueryInterface(&pcf);
 // create a call object for AsyncIBob
   CComPtr<ISynchronize> pCall;
   pcf->CreateCall(__uuidof(AsyncIBob), 0,
              __uuidof(pCall), (IUnknown**)&pCall);
 // QI call object for async interface
   CComPtr<AsyncIBob> pBob;
   pCall->QueryInterface(&pBob);
 // send request
   pBob->Begin_HiBob(52);
 // poll for completion every second
   while (pCall->Wait(0, 1000) != S_OK);
 // harvest out params
   return pBob->Finish_HiBob(pn);
 }