[GIS] With ArcObjects, distinguish between Save Edits with and without closing the current edit session

arcobjects

Is it possible with ArcObjects to distinguish between the user selecting the Save Edits button and the users selecting the Stop Editing button and then saving edits?

The reason for this is that in the IEditEvents.OnStartEditing event I am acquiring references to certain tables based on the current editor workspace. These tables are used to acquire configuration parameters for an ArcMap extension and for other purposes throughout the edit session. When the edit session is closed, I clear the references to those tables and arrays generated from those tables.

The issue this has created is that when the user selects "Save Edits", IEditEvents.OnStopEditing is called followed by IEditEvents.OnStartEditing. Essentially, ArcMap is starting a new edit session. Thus, the work done during the OnStartEditing event is rerun, even though the user hasn't ended the current edit session. There is some overhead to that work that I would like to avoid if possible.

I have a workaround involving setting a shared property to the current edit workspace on the StopEditing event, and comparing that property to the new edit workspace on the StartEdting event. If they are the same then I know the edit workspace hasn't changed and I don't need to rerun the work to get table references and so forth. It seems a little messy though. I recall reading something about this at one point but can find no discussion regarding it on this forum or ESRI's.

Best Answer

Use IEditEvents2.OnSaveEdits to set a flag to avoid having to reload your config.

The OnSaveEdits event is fired whenever a user issues the Save Edits command in the Editor. This event is not raised when a user stops an edit session and chooses to save edits, or if IEditor::StopEditing is called.