Update KmlLayer ArcGis Runtime SDK .NET

2750
0
09-23-2015 06:58 AM
JasonTrinidad1
New Contributor III

I am having an issue with updating a KmlLayer in MySceneView.Scene.Layers. This is constantly updated at less than 30fps. I have multiple threads (max of 4) calling this function, each has a unique ID. The contents of the kml changes, but the URI remains the same (each thread also has its own kml with different Uri). The problem I'm having is that my application is randomly crashing after running for about a minute, and it's not telling my why. It just says MyProgram has stopped working.

Monitor.Enter(MySceneView.Scene.Layers);
try
{
    var kmlLayer = new KmlLayer(sourceUri); //sourceUri is a local file
    kmlLayer.ID = id;
    kmlLayer.Opacity = _alpha;
    kmlLayer.IsVisible = _visibility;
    kmlLayer.InitializeAsync();
    if (MySceneView.Scene.Layers[id] != null)
         MySceneView.Scene.Layers.Remove(id);
    MySceneView.Scene.Layers.Add(kmlLayer);
}
finally
{
    Monitor.Exit(MySceneView.Scene.Layers);
}

Also tried replacing the layer instead of removing it, but it also crashes

if (MySceneView.Scene.Layers[id] == null)
    MySceneView.Scene.Layers.Add(kmlLayer);
else
{
    for (int i = MySceneView.Scene.Layers.Count - 1; i >= 0; i--)
    {
        if (MySceneView.Scene.Layers.ID == id)
        {
           MySceneView.Scene.Layers = kmlLayer; //I cant replace the layer using the id as an index, since it's read only using a string index
        }
    }
}

Any help would be appreciated

0 Kudos
0 Replies