Skip to content

Commit

Permalink
make EventProxy thread aware so that unadvice will be called in the c…
Browse files Browse the repository at this point in the history
…ontext of the connection point owner
  • Loading branch information
protogenes authored and Michael Kunz committed Jan 5, 2017
1 parent 1e690b8 commit 976ac65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions runtime/src/main/java/com4j/EventProxy.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class EventProxy<T> implements EventCookie {

private final EventInterfaceDescriptor<T> descriptor;
private final T javaObject;
private final ComThread thread;

/**
* Pointer to the native proxy.
Expand All @@ -35,9 +36,10 @@ final class EventProxy<T> implements EventCookie {
* Creates a new event proxy that implements the event interface {@code intf}
* and delivers events to {@code javaObject}.
*/
EventProxy(Class<T> intf, T javaObject) {
EventProxy(Class<T> intf, T javaObject, ComThread thread) {
this.descriptor = getDescriptor(intf);
this.javaObject = javaObject;
this.thread = thread;
}

/**
Expand All @@ -50,7 +52,7 @@ public Void call() {
Native.unadvise(nativeProxy);
return null;
}
}.execute();
}.execute(thread);
nativeProxy = 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/main/java/com4j/Wrapper.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public EventProxy<?> call() {
throw new ComException("This object doesn't have event source",-1);
GUID iid = COM4J.getIID(eventInterface);
Com4jObject cp = cpc.FindConnectionPoint(iid);
EventProxy<T> proxy = new EventProxy<T>(eventInterface, object);
EventProxy<T> proxy = new EventProxy<T>(eventInterface, object, thread);
proxy.nativeProxy = Native.advise(cp.getPointer(), proxy,iid.v[0], iid.v[1]);

// clean up resources to be nice
Expand Down

0 comments on commit 976ac65

Please sign in to comment.