Access Java application message loop from JNI code.
posted 6 years ago
Anyone know how to access a Java application's message loop from inside JNI code?
Through the (JNIEnv *env) or (jobject obj) parameters maybe?
I've got an ActiveX dll that I'm running via JNI. The ActiveX dll creates an IP server on a separate thread. When another process connects to the IP server I need to PostMessage (MS Windows term) from this IP server thread to the thread that the Java application is running on.
It appears the Java application's message loop is not present or available in the JNI code and consequently the message is never posted from the IP thread to the JNI / Java App thread.
Of course I can manually add a message loop to the JNI code and the PostMessage works just fine. But then the message loop is executing and the Java application is effectively blocked and becomes unresponsive because the JNI method call never returns as its busy running this while loop doing a GetMessage --- DispatchMessage inside the ActiveX dll.