Select to view content in your preferred language

onRowChangedEvents triggering for different edit session

411
1
01-29-2020 05:04 AM
SreenivasaRaoPigili
Regular Contributor

Hi All,

   Currently we are having multiple edit modules in the project.

For example, EditModule1 --> will perform Split functionality on FeatureClass1.

                      EditModule2 --> will perform Extent functionality on FeatureClass2.

In both the scenarios - we need to observe the feature classes changes. So, we have implemented onRowChangedEvent on featureclass1 with business logic1.

onRowCreatedEvent got implemented on featureclass2 with business logic2.

But the problem is - whenever there is a change in featureclasse 2 , onRowChangedEvent is getting triggered.

I have unsubscribed this event after completion of Edit session1. But no luck.

Please find the sample code snippet below.

//Creating the Edit Operation
await QueuedTask.Run(() =>
{
         ActiveMapView.SelectFeatures(geometry);

      var editOp = new EditOperation();
      editOp.Name = "Edit Module1";
      editOp.SelectModifiedFeatures = true;
      editOp.SelectNewFeatures = true;
      if (_rowChangedToken == null)
      {
               _rowChangedToken = ArcGIS.Desktop.Editing.Events.RowChangedEvent.Subscribe(onRowChangedEvent,                                                    featureLayer.GetTable());
      }

//some extra lines of code to call split functionality.

      //Execute the Edit Operation
      editOp.Execute();
       ArcGIS.Desktop.Editing.Events.RowChangedEvent.Unsubscribe(_rowChangedToken);
});

Question 1: if i am not wrong, we can implement multiple Row Events on single project. But we have to unsubscribe the events (in each module wise) properly. Please correct me - if this is not the scenario.

2. Please correct me what is the mistake in my approach and why this event is getting triggered from other edit modules.

Is there any good example i can refer to understand this completely.

Thank you in advance.

0 Kudos
1 Reply
by Anonymous User
Not applicable

Hi there,

Question1: Yes you can implement multiple row events throughout a project but you also have to maintain the lifetime of each. i.e when to subscribe/unsubscribe for your workflow.

Question2: I cant evaluate your approach without seeing the whole code (probably not practical) or at least a sample project illustrating the problem but it should work....

In your code above you'll want to set _rowChangedToken to null after the unsubscribe, otherwise it wont resubscribe if the variable is still in scope.

Check the spelling of your row subscription events, as more than once ive subscribed to the wrong event because they're similarly named.

There are a few rowevent samples in the community samples repo but probably none that have them in multiple modules.

0 Kudos