Why does the ArcGISLocalFeatureLayer.UpdateCompleted event fire twice?

Discussion created by reneecammarere on Aug 14, 2013
Latest reply on Aug 15, 2013 by reneecammarere
I have the following routine that gets the local feature layer service that is used for editing a feature class.  For some reason, it goes through the arcGISLocalFeatureLayer.UpdateCompleted  event twice.  This causes a runtime error due to the lines in which I re-project the aGraphic object.  I don't understand why this is happening.

       private void EditMyFeatureLayer()
            // Get the Local Feature Layer service that is used for editing the Result feature class (map package)
            string mpkPath_features = ConfigurationManager.AppSettings["EsriRuntimeEditMapPackageLocation"];

            LocalFeatureService localFeatureService = LocalFeatureService.GetService(mpkPath_features);
            //CoverAreasResult Feature
            arcGISLocalFeatureLayer = new ArcGISLocalFeatureLayer();
            arcGISLocalFeatureLayer.Service = localFeatureService;
            arcGISLocalFeatureLayer.Editable = true;
            arcGISLocalFeatureLayer.ValidateEdits = true;
            arcGISLocalFeatureLayer.LayerId = 0;
            arcGISLocalFeatureLayer.ID = "CoverAreasResult";
            arcGISLocalFeatureLayer.Path = mpkPath_features;
            arcGISLocalFeatureLayer.DisableClientCaching = true;
            arcGISLocalFeatureLayer.AutoSave = true;
            arcGISLocalFeatureLayer.Mode = ESRI.ArcGIS.Client.FeatureLayer.QueryMode.Snapshot;
            arcGISLocalFeatureLayer.ShowLegend = true;
            GraphicCollection aGCollection = arcGISLocalFeatureLayer.Graphics;
            arcGISLocalFeatureLayer.Initialized += (sender, eventArgs) =>

            arcGISLocalFeatureLayer.UpdateCompleted += (sender, e) =>
                ESRI.ArcGIS.Client.Projection.WebMercator aProjector = new WebMercator(); // constructor for easy client projection (102100 <-> 4326)
                foreach (Graphic aGraphic in _gpFeatureRecordSetLayer.FeatureSet.Features)
                    aGraphic.Geometry = aProjector.ToGeographic(aGraphic.Geometry); // project graphic geometry to WGS84
                    aGCollection.Add(aGraphic);                // add projected graphic to graphic collection
                arcGISLocalFeatureLayer.Graphics = aGCollection;

                //  See above reference - don't need to project layer if going between WGS84 and Web Mercator

                _map.Layers.Insert(1, arcGISLocalFeatureLayer);