GeoMedia Discussions

Search for an answer, post a question, or answer other users' questions in our GeoMedia support discussions. This discussion board is a great way to collaborate with industry peers around the world. It is intended for discussion and support of the GeoMedia Desktop and Add-on applications.
Showing results for 
Search instead for 
Do you mean 
Posts: 39
Registered: ‎11-02-2017
Accepted Solution

Can you call GeoMedia functions from a separate thread?

[ Edited ]



I have an application that makes numerous GeoMedia connections on the UI thread. I then have another thread where I want to access some of this information. A call to any of the GeoMedia connections on the new thread causes the error below.


DBUtilities.vb(307): 2019-11-08 11:50:40,995 [10][ERROR]: Invalid geometry object; does not support IGMGeometry.
System.ArgumentException: Invalid geometry object; does not support IGMGeometry.
   at Intergraph.GeoMedia.PClient.GeometryStorageServiceClass.SetGeometry(GField field, Object Geometry)
   at My.Common.DbUtilities.SetGeomWithRec(GRecordset& rs, Object& objGeom, String& geomFieldName) in C:\Development\My.Common_GM\DBUtilities.vb:line 300

The only way I can get this to work is by Invoking the call back on to the main thread. 


Is it possible to call a GeoMedia function on a thread other than the one it was created on? 


I read that this might be possible in GM2016.2 patch 3. Is that the case?


Many thanks for your help!




Technical Evangelist
Posts: 549
Registered: ‎09-11-2015

Re: Can you call GeoMedia functions from a separate thread?

Hi Adrian,


most of the GeoMedia COM objects (including Connection) are not thread safe. So indeed the only way to call them is from the application main thread, or more precisely, from the thread which handles the application message loop. If you want to access for example the same database from different threads, then you can create two or more executables and let them communicate each other via an inter process communication mechanism, such as DDE.



Regular Contributor
Posts: 222
Registered: ‎05-25-2016

Re: Can you call GeoMedia functions from a separate thread?

Hi Adrian


I am not sure, I understood correctly what you want to do.


You can call GeoMedia commands using the Windows API function PostMessage.


But when I look at your error message, I think it's not a problem with thread crossing.

I guess there is a problem with the value of Object Geometry. Is this a blob value (not a GDO geometry object) in your case?


It may work, if you use the GeometryToStorage method instead of SetGeometry and set the GField to the outputed chunk of this method.


Best regards