Search code examples
vb.netarcobjectsarcmap

How do I capture an application close event of an application hosting my vb.net class libary tool?


I have a set of tools that I've built as a class library that is hosted/referenced within a main application (ESRI's ArcMap). I'd like to manage the case where a user may pull the pin on the main application while they have unsaved/unmanaged edits pending. I tried handling the Application.ThreadExit event w/ no success. Is there a best practice for accessing the closure of a hosting application in .Net? Is this even possible?


Solution

  • There is an event handler for the currently opened document in ArcMap. Have a look here:

    http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/BeforeCloseDocument_Event/000v000000pn000000/

    You can listen to the BeforeCloseDocument_Event and develop some logic to handle the case of a closing document (the document is closed when the application is closed).