0

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?

1
  • 2
    This sounds like something which really should be implemented in the application and not in the class library. As long as your class library provides methods to get the state of unfinished business it should be the main application's responsibility to call them and sort out with the user what it should do with unsaved work, etc. Why do you want to do this in the class library?
    – J...
    Commented Apr 30, 2012 at 19:25

2 Answers 2

1

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).

0

Since a typical WinForms application doesn't close until the main form is closed, you could have the class library handle the host application's main form FormClosing event. To prevent the application from closing, you would set the FormClosingEventArgs object's "Cancel" property to true.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.