com4j
com4j copied to clipboard
Marshalling between threads when using COM4J.wrap
When constructing a wrapper from a C pointer to an interface using COM4J.wrap, all subsequent method calls on that object are done on a com4j.ComThread. This isn't the same thread that was used to create the object, and so it will cause problems.
When wrapping the pointer, com4j should marshal the object across to its com4j.ComThread instead of just taking the pointer.
One possible solution would be to use RegisterInterfaceInGlobal/GetInterfaceFromGlobal to pass a handle across the thread boundary and add a call to RevokeInterfaceFromGlobal when releasing the native object.
Is this something that anyone else has come across? Have I missed something, or is using COM4J.wrap not the right thing to be using for this purpose?
I'm happy to make the changes necessary, but is this project still being actively maintained by anyone? Are my changes likely to be merged?