e.d. wrote What's interesting though is that every blocking method (for instance also an alert dialog) suspends the entire event chain, which in my view should not happen! When I dispatch an event before the blocking happens, it should be triggering the handler, shouldn't it? What are your thoughts on this? I am unclear as to what you specifically mean by "should be triggering the handler", but I will take a guess and say that you mean "calling a registered CEP listener when an ExtendScript CSXSEvent event is dispatched." To be honest: I have no idea. Whether the event is triggered immediately simply queued up for later delivery when you call CSXSEvent.dispatch() is an implementation detail. Based on your explanation, I would guess that the function queues up the event for delivery during a separate processing phase on the thread. This would be similar to the way that calling setTimeout(func, 0) in a browser does not immediately call the function, even though it should have a 0ms delay - it is put in a queue for processing during the next frame. In the case of the CSXSEvent class, this would depend on the underlying implementation to which we do not have any insight. Perhaps Bruce Bullis​ could offer a more definitive answer as to what's going on with CSXSEvent.dispatch under the hood. That said, my thoughts are that this is not-at-all surprising. You are likely adding an event to a queue but blocking the thread before the thread has a chance to process that queue. That would be my best guess. Basically: avoid blocking calls if you can! e.d. wrote You're mostly right, one needs to specify the handler on removal as well, which is why it's not a good idea to use an anonymous function. Again, this seems to be mandatory, the object seems to be optional, considering the CSInterface.js implementation. Well, the first paragraph I wrote says basically the exact same thing, simply worded differently. The second paragraph was pointing out a potential option to try as do not like to assume I understand something in the CEP/Premiere SDK, even when there's documentation. The reason I wrote the second paragraph is because I could see a situation wherein Adobe implemented a way to "remove all event listeners for a given object and a given 'type' by calling cs.removeEventListener("someEvent", null, myObj);". I have actually written event systems that have just such a mechanism - even ones that support removing all registered listeners for a specified object, across all event "types". That said, I will admit now that this makes far less sense given that the setup is mirrored in the cs.addEventListener function parameters and I can't see a way that it makes sense to call cs.addEventListener("someEvent", null, myObj); in a useful way. I've still not tested anything along these lines but I'd be willing to bet that calling the add/removeEventListener functions without specifying a function and specifying an object will simply fail silently. Some error handling either way (in this case or the one you encountered, with an undefined function handler) would probably be a big help in the future... I'm glad my answer was helpful. I similarly hope that this one is.
... View more