Title explains it all. Execution is blocked at GetEvent, and only resumes if I give the function a finite timeout value as argument. Here's my event listener code using VB API version 5.1.14 (VB app is 5.1.12)
Code: Select all
......................
session->get_Console(&console);
auto msev_func = [](LPVOID p){
//
IConsole *console = (IConsole*)p;
IEventSource *es;
HRESULT rc = console->get_EventSource(&es); //get_VMerr(rc, "evso get"); // error description function - successful in all instances
IEventListener *listener; es->CreateListener(&listener); //get_VMerr(rc, "evli creat"); // error description function - successful in all instances
VBoxEventType aTypes[] = { VBoxEventType::VBoxEventType_Any };
SAFEARRAY * psa;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 1;
psa = SafeArrayCreate(VT_INT, 1, rgsabound);
LONG rgIndex = 0;
HRESULT hr = SafeArrayPutElement(psa, &rgIndex, aTypes);
int otyp;
// list of event types to listen for
es->RegisterListener(listener, psa, false /* active */); get_VMerr(rc, "evli reg"); // error description function - successful in all instances
// register passive listener111
SafeArrayGetElement(psa, &rgIndex, &otyp); // test value
printf("want: %d\n is: %d\n", VBoxEventType::VBoxEventType_OnMousePointerShapeChanged, otyp); // test is successful
while (1)
{
IEvent *ev;
hr = es->GetEvent(listener, -1, &ev); get_VMerr(rc, "evli get"); // error description function - successful in all instances of this code
if (ev != nullptr){
// downcast to specific event interface (in this case we have only registered
// for one type, otherwise IEvent::type would tell us)
printf("evented");
IMousePointerShapeChangedEvent *mcse;
mcse->QueryInterface(&ev);
// inspect and do something
//
es->EventProcessed(listener, ev);
}
}
es->UnregisterListener(listener);
return (DWORD)2;
};
HANDLE hThread;
DWORD dwThread;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)msev_func, console, 0, &dwThread);
WaitForSingleObject(hThread, INFINITE);