[gme-users] communicating with the GME environment

Belschner, Tim tim.belschner at ils.uni-stuttgart.de
Mon Jun 15 02:40:11 CDT 2015

Dear Kevin,

thanks a lot for the clarification and the two approaches.

It will simplify the start.



Von: gme-users [mailto:gme-users-bounces at list.isis.vanderbilt.edu] Im Auftrag von Kevin Smyth
Gesendet: Mittwoch, 10. Juni 2015 22:49
An: A list for GME users to share thoughts and discuss bugs and fixes.
Betreff: Re: [gme-users] communicating with the GME environment


I would warn you that this cannot be completely reliable, since you don't know what state GME is in when you receive a message. The user could be in the Tools>Register Components... window, or running an interpreter, or who knows what. It is up to the user to have GME in a state that is ready for incoming messages.

If you can live with this constraint, an add-on or interpreter can be used for this: start a thread, and listen to your socket there. Since GME COM objects are apartment-threaded, you cannot directly access GMEApplication or the model from a different thread. I'd recommend one of two approaches: 1. when your addon or interpreter starts, create a hidden window, then your thread can Post/SendMessage to that hidden window and do processing on the main thread; 2. use CoMarshalInterThreadInterfaceInStream to pass COM interfaces to your thread. Of course, both of these approaches require that GME is pumping messages (e.g. not running an interpreter).

When GME is pumping messages, it is typically not in a model transaction. But some interpreters pump messages during a transaction, so you may want to check IMgaProject::ProjectStatus.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20150615/c70d817a/attachment.html>

More information about the gme-users mailing list