imoratiel

Layers crashing app from a different thread

Discussion created by imoratiel on Sep 13, 2013
Latest reply on Sep 24, 2013 by akajanus-esristaff
In my apps I add lots of layers, from different sources, and sometimes one of them closes my app ignominiously, for example:

- Adding a layer from bing map without internet connection
- Adding a secured Arcgis server layer, without adding user and password. This is really a problem because users can add AG server layers by typing URL
- Few days ago, Open Street Map server was down about 2 hours, everything was failing
- Unpacking MPK files, this is a random error. Sometimes it works, sometimes it crashes

I see some problems:

- There is no chance to know if a layer object is properly created or not. Maybe I didn't find it, but a Tiled layer with an impossible URL looks fine, it will f**k you later, when showing the map
- Apparently, API creates a new thread, apart from main thread, so you can't catch exceptions, you can't check if app will crash, and everything else. Only way to fix this is with a exception handler running from app base, but is a dirty solution, because it's difficult to know if the exception is caused by a layer, and which layer is crashing

I think that would be very useful a function named IsGoingToCrashEverythingWithThisLayer(layer) so I can check this before adding it to map. Is there anything similar?

Outcomes