Hello, I'm using version 100.12
My program can have a-lot(can be 10k or even more) of graphics on screen on the same time(static graphics)
when I work with small or even medium amount of graphics all works fine and well
But when i work with large amount of graphics, after I delete the graphics from my GraphicCollection(and i checked the count is 0 as expected) the graphics does not disappear from the screen
P.S
Adding graphics to the screen ALWAYS works fine( when i add 10k+ graphics it takes like 5-6 seconds to fully render to the screen)
P.S2
I tried to mess around the Partitioner and the Parallel.ForEach parameters but the result stays the same
P.S3
Changing all Parallel.ForEach not Iterative Foreach yields the same problem
P.S4
GraphicCollection.Clear() yields the same problem
private static readonly ConcurrentDictionary<string,Symbol> SymbolDictionary = new ConcurrentDictionary<string,Symbol>();
private readonly ConcurrentBag<Graphic> _slideGrahpics = new readonly ConcurrentBag<Graphic>();
private readonly PolylineBuilder _polylineBuilder = new PolylineBuilder(SpatialReferences.Wgs84);
private readonly PolygonBuilder _polygonBuilder = new PolygonBuilder (SpatialReferences.Wgs84);
public void CreateMapElement(){
var partitioner = Partitioner.Create(Items, EbumerablePartitionerOptions.NoBuffering);
Parallel.ForEach(partitioner, new ParallelOptions(){MaxDegreeOfParallesim = 400 , TaskScheduler = TaskScheduler.fromCurrentSynchronizationContext() }, item => {
try
{
if(item == null || string.IsNullOrEmpty(item.SymbolJson)) return;
Symbol symbol;
if(SymbolDictionary.ContainsKey(item.SymbolJson))
symbol = SymbolDictionary[item.SymbolJson);
else
{
symbol = Symbol.FromJson(item.SymbolJson);
SymbolDictionary.TryAdd(item.SymbolJson, symbol);
}
if(!Enum.TryParse(item.GeometryType, ignoreCase: true, result : out GeometryType geometryType)) return;
Grahpic grahpic = null;
switch(geometryType)
{
case GeometryType.Point:
grahpic = CreateGraphic(item.SymbolLocation.First(), symbol);
break;
case GeometryType.Polyline:
grahpic = CreateGraphic(_polylineBuilder,item.SymbolLocation, symbol);
break;
case GeometryType.Polygon:
grahpic = CreateGraphic(_polygonBuilder,item.SymbolLocation, symbol);
break;
}
if(grahpic == null) return;
grahpic.Attributes[MapConstants.LabelKey] = item.Label;
_slideGrahpics.add(grahpic)
}
catch(Exception ex) {//Handle Exception }
});
}//end CreateMapElement
private Graphic CreateGraphic<T>(MultipartBuider<T> buider, IEnumerable<MapPoint> coordinateCollection, Symbol symbol) where T : Multipart
{
builder.Parts.Clear();
foreach(var coordinate in coordinateCollection)
{
builder.AddPoint(coordinate);
}
return CreateGraphic(builder.ToGeometry(), symbol);
}//End CreateGraphic<T>
private Graphic CreateGraphic(Geometry geometry, Symbol symbol) => new Graphic(geometry, symbol); //end CreateGraphic
//this method called AFTER CreateMapElement is finished
private void UpdateActualLayer(string layerId)
{
var partitioner = Partitioner.Create(_slideGrahpics, EbumerablePartitionerOptions.NoBuffering);
Parallel.ForEach(partitioner, new ParallelOptions(){MaxDegreeOfParallesim = 400 , TaskScheduler = TaskScheduler.fromCurrentSynchronizationContext() }, grahpic=> {
GraphicCollection.Add(grahpic);
});
}//end UpdateActualLayer
//this method called on user click
private void RemoveFromActualLayer(string layerId)
{
var partitioner = Partitioner.Create(_slideGrahpics, EbumerablePartitionerOptions.NoBuffering);
Parallel.ForEach(partitioner, new ParallelOptions(){MaxDegreeOfParallesim = 400 , TaskScheduler = TaskScheduler.fromCurrentSynchronizationContext() }, grahpic=> {
GraphicCollection.Remove(grahpic); //this is 0 when the loop is done
});//changing to iterative foreach yields the same result
}//end RemoveFromActualLayer
Hi,
Can you try updating to version 100.15.2 and retesting?
Thanks
I need to check if i can upgrade
but in the meanwhile is there anything i can do?