API docs don't explicitly say, but is the GraphicCollection class thread safe? Use case is that I have a large(ish) number of graphics (25,000 to maybe 100,000) to add to an overlay. Can this task be safely chunked into batches and run in parallel?
The GraphicCollection class is indeed thread-safe (synchronized). However, the most efficient way to populate it would be to use AddRange method (optimized to reduce temporary allocations and locking/unlocking/eventing overhead). So, yes, you can absolutely parallelize creation of your Graphic objects -- e.g. using Parallel.ForEach with a partitioner -- but I suggest adding Graphics to the collection in batches of several hundred/thousand rather than individually.
We actually have a whole guide topic dedicated to Graphic performance, check it out for more tips: Performance considerations | ArcGIS Maps SDK for .NET | ArcGIS Developers
A couple years ago we also talked about performance for Graphic-heavy apps at DevSummit. You can find a recording of it here: "ArcGIS Runtime SDK for .NET: Building Apps - Part 2" (relevant part starts around the 25-minute mark).
Thank you, this is all very useful. 🍻
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.