<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proper use of IEditor (StartOperation / StopOperation) in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639046#M17194</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try a "Try Catch" block to catch exception.&amp;nbsp; I like to also use a boolean variable to let me know if I am in an edit operation or not.&amp;nbsp; That way if my "Try Catch" encounters an exception then I can decided how to clean up the edit.&amp;nbsp; Ususally involves stopping the edit operation and not saving any changes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Mar 2011 22:22:15 GMT</pubDate>
    <dc:creator>SteveFang</dc:creator>
    <dc:date>2011-03-16T22:22:15Z</dc:date>
    <item>
      <title>Proper use of IEditor (StartOperation / StopOperation)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639045#M17193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having some problems getting IEditor to behave in a stable manner.&amp;nbsp; If everything goes right in my code, then all is good, but if something unexpected happens (e.g. try to put too much data into a small field) it screws up the editor operation stack (I think) and then I basically need to restart ArcMap. It seems like I might get errors when I call Store, StartOperation, or even StopOperation. It kinda seems to vary. QUESTION: How can I rewrite the code below to keep things in a good state if something unexpected happens? Is there some key method like IsInEditOperation that I am missing as part of good defensive coding techniques. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Essentially my code looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;bool hadToStartEditing = false;
if(editor.EditState == esriStateNotEditing)
{
&amp;nbsp; editor.StartEditing();
&amp;nbsp; hadToStartEditing = true;
}
editor.StartOperation();
//...More code to create a new feature &amp;amp; set it's shape / subype
// ...More code to set values on various fields (hopefully legal values, but perhaps not always)
editor.StopOperation();
if(hadToStartEditing)
{
&amp;nbsp; editor.StopEditing(True);
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Mar 2011 16:47:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639045#M17193</guid>
      <dc:creator>RiverTaig1</dc:creator>
      <dc:date>2011-03-16T16:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proper use of IEditor (StartOperation / StopOperation)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639046#M17194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try a "Try Catch" block to catch exception.&amp;nbsp; I like to also use a boolean variable to let me know if I am in an edit operation or not.&amp;nbsp; That way if my "Try Catch" encounters an exception then I can decided how to clean up the edit.&amp;nbsp; Ususally involves stopping the edit operation and not saving any changes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Mar 2011 22:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639046#M17194</guid>
      <dc:creator>SteveFang</dc:creator>
      <dc:date>2011-03-16T22:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proper use of IEditor (StartOperation / StopOperation)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639047#M17195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apart from Try Catch.. Finally block should also be implemented where in case of failure you can stop edit operation and edits.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nikhil&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 May 2011 09:38:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639047#M17195</guid>
      <dc:creator>nikhilsastikar</dc:creator>
      <dc:date>2011-05-10T09:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proper use of IEditor (StartOperation / StopOperation)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639048#M17196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I always do the try catch block as a matter of fact for every edit operation, I usually call abort operation in the catch block regardless of the error.&amp;nbsp; This way in the case of any unforeseen error, I stop the operation without messing up the call stack.&amp;nbsp; Any foreseen error, you are better off handling before it raises an error.&amp;nbsp; I never use abort operation in event listeners raised inside the operation, for that I just throw my own exception and the esri framework aborts the operation and pops up a message.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 May 2011 13:32:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/proper-use-of-ieditor-startoperation-stopoperation/m-p/639048#M17196</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2011-05-10T13:32:43Z</dc:date>
    </item>
  </channel>
</rss>

