Vishful thinking…

Things to note when using multi-threading in ArcObjects

Posted in ArcGIS, ESRI by viswaug on August 27, 2007

Here are some of my observations when using multi-threading in ArcObjects applications

  • Different threads can be used to perform operations that are totally disconnected from the objects in the running instance of the ArcGIS applications. In other words, it is safe to create to a thread that connects to a SDE, opens a featureclass and performs some geometry operations on the features in the featureclass and disconnects after completion. Another use case is to open or create a MXD file and add layers to its map contents and close the MXD when done.
  • Don’t access objects created in the running instance of the ArcGIS applications in a different thread. Thats is, don’t pass a reference to the map object or the goemetry of the selected feature to a different thread and perform operations on it in the thread. If you do, things start behaving weird.
  • When you are automating ArcGIS applications from a different application(different process space and not different thread), use the IObjectFactory interface to create objects in the ArcGIS process space.

Brian Flood has written a couple of blog entries (“Background Processing” and “Background Processing Redux“) on this subject if you are interested in reading more.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: