Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Variant conversion in same ComThread #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vezjakv
Copy link

@vezjakv vezjakv commented Mar 29, 2015

Variant conversion gets blocked when calling from same ComThread.
For example, this happens in asynchronous COM event handling when
iterating through properties of received COM object in event handler:

ISWbemSink sink = ClassFactory.createSWbemSink();
sink.advise(ISWbemSinkEvents.class,new ISWbemSinkEvents() {
    public void onObjectReady(ISWbemObject object, ISWbemNamedValueSet asyncContext) {
        System.out.println("Received event: " + object.getObjectText_(0));
        for (Com4jObject oprop: object.properties_()) {
           ISWbemProperty prop = oprop.queryInterface(ISWbemProperty.class);
           System.out.println(prop.name() + ": " + prop.value());
        }
    }
});

The above code will block in iterator part when retrieving and converting Variants.
The solution is to do conversion in Variant's ComThread if the same as calling ComThread.

Variant conversion gets blocked when calling from same ComThread.
For example, this happens in asynchronous COM event handling when 
iterating  through properties of received COM object. The solution is to
do conversion in Variant's ComThread if the same as calling ComThread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant