How to run an ActiveX component method without blocking the possessing control?

  activex, c++
BSTR CCtrl::mosMsgFromHost(BSTR mosMsg)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    AfxMessageBox(mosMsg);
    mainDialog.GetWebView()->PostWebMessageAsString(mosMsg);
    std::unique_lock<std::mutex> ul(m);
    cv.wait(ul);
    AfxMessageBox(mainDialog.receivedMessage);
    return mainDialog.receivedMessage.AllocSysString();
}

I have laid out a WebView2 component in ActiveX Control. When its following method is called, it forwards the message it gets to WebView2 to be processed and returned by means of an event that notifies cv, which is the condition variable so that it continues to the rest below cv.wait(ul).

Everything is fine and working like a charm but the issue here is blocking the entire ActiveX control while it is waiting. I cannot tweak at the client side that uses the ActiveX control we’re designing, so I cannot make it Asynchronous ActiveX control. So is there any recommendation to solve this issue?

Source: Windows Questions C++

LEAVE A COMMENT