title: Non-blocking function calls with Boost
body: <p>I have this function that is called from Javascript (Browser):</p>
  
  <pre><code>STDMETHODIMP CActivexObject::WriteToREST(BSTR data, BSTR* retstr)
  {
      std::string sdata = ConvertToString(data);
      RESTClient restclient;
      RESTClient::response resp = restclient.post("somewhere.com", "/post", sdata);
      CComBSTR bstrResult(resp.body.c_str());
      *retstr = bstrResult.Detach();
      return S_OK;
  }
  </code></pre>
  
  <p>This method is called from the Javascript like this:</p>
  
  <pre><code>for (var i = 0; i &lt; rowElems.length; i++) {
       var resp = ActivexObject.WriteToREST(_rowToData(rowElems[i]));
  }
  </code></pre>
  
  <p>The function works fine, unless the call to REST or the server gets slow, and the Javascript (Browser), i.e. Internet Explorer to show "Not Responding" error box. Then browser shuts down. If I remove the "post" call and just log the data, the there's no such error like this. </p>
  
  <p>Sometimes the <code>WriteToREST</code> is called twice or three times. </p>
  
  <p>What could be a possible solution for this that I can make with the C++ code?</p>