JNI: COM event sinks in a DLL

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top