A
Arthur Brack
hello,
I have created an Event-Sink class in C++ to handle COM-Events and it
works well in a MFC-application.
But if I create a DLL to use this Event-Sink-Class with the JNI then
the callback function of the event-sink is not called. The COM-Server
tells me that it is "overloaded" when it fires the event. It seems to
me that it "hangs" somehow in the JVM.
here some pseudo code:
in Java:
class Test {
public static native void nativeFunction();
public static void main(...) {
nativeFunction();
//during sleeping I fire the "event"
Thread.sleep(30000);
}
}
in the DLL:
class EventSink : public IDispatch
{
...
HRESULT __stdcall Invoke(...) {
//just exit application
exit(0);
return S_OK;
}
...
};
JNIEXPORT void JNICALL ...nativeFunction(...)
{
//initialize COM
CoInitializeEx(NULL, COINIT_MULTITHREADED);
//create COM object with CoCreateInstance(...)
//get IConnectionPointContainer of the object
//get IConnectionPoint* connectionPoint
//advise sink to connectionPoint
EventSink* sink = new EventSink();
connectionPoint->advise(sink, &cookie);
...
}
what is wrong in the code?
thanks in advance!
Arthur
I have created an Event-Sink class in C++ to handle COM-Events and it
works well in a MFC-application.
But if I create a DLL to use this Event-Sink-Class with the JNI then
the callback function of the event-sink is not called. The COM-Server
tells me that it is "overloaded" when it fires the event. It seems to
me that it "hangs" somehow in the JVM.
here some pseudo code:
in Java:
class Test {
public static native void nativeFunction();
public static void main(...) {
nativeFunction();
//during sleeping I fire the "event"
Thread.sleep(30000);
}
}
in the DLL:
class EventSink : public IDispatch
{
...
HRESULT __stdcall Invoke(...) {
//just exit application
exit(0);
return S_OK;
}
...
};
JNIEXPORT void JNICALL ...nativeFunction(...)
{
//initialize COM
CoInitializeEx(NULL, COINIT_MULTITHREADED);
//create COM object with CoCreateInstance(...)
//get IConnectionPointContainer of the object
//get IConnectionPoint* connectionPoint
//advise sink to connectionPoint
EventSink* sink = new EventSink();
connectionPoint->advise(sink, &cookie);
...
}
what is wrong in the code?
thanks in advance!
Arthur