Hello,
I want to fire/propagate an Event in Delphi Host from C# plugin.
I declared interface IMyHost and Host’s application main form is inherited from IMyHost.
Then by some reason in C# plugin this.Host appears not to be IMyHost
Do we have some basic example of Callbacks/Events from C# to Delphi?
The code there is old and might not even build in the latest Hydra versions, still you should see the approach where host sets the callback site and plugin raises its events:
Thank you Anton,
in general it works!
Main Idea is to register(e.g. SetEventSink ) Host with Plugin by passing there
Host’s inteface (e.g. ImyInterfaceEvents).
Then from the Plugin the Host’s Interface can trigger a method in Host.
In my code it all works if I’m firing the event from main thread of the Plugin,
but my Plugin uses Threads and If I call the event from threaded function I’m getting the following error:
ex.Message "Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘MyModule.IMyHost’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{EA13C76E-47C9-49C6-A0A8-65D701B99C65}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."
Are there some tweaks to handle such issue?
Thanks in advance,
Unfortunately COM doesn’t like multithreaded access (ie plugins cannot be asccessed from other threads). You need to somehow perform all plugin calls from the same thread.