minerjoe

Why no timeout for loading online layers?

Discussion created by minerjoe Champion on Apr 27, 2020
Latest reply on Apr 29, 2020 by mnielsen-esristaff

We use online basemaps for a mobile application.  It is possible, however, that a user may not have connection at some locations.  What happens in this situation is that the Layer:LoadAsync() for the ArcGISVectorTiledLayer simply hangs up.   It never times out and shows a failure to load.

 

var layerUri = new Uri("https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer");

var tiledLayer = new ArcGISVectorTiledLayer(layerUri);

//hanges up at this line of code.  LoadStatus goes into Loading but never changes
await tiledLayer.LoadAsync();

 

Instead I am having to add code to determine if it times out.   I used an HttpClient to see if I can hit the endpoint.

 

try
{
     //will timeout if unable to connect
     using (HttpClient client = new HttpClient(){Timeout = TimeSpan.FromSeconds(1)})
     {
          await client.GetStringAsync(layerUri);

          await tiledLayer.LoadAsync();
          map.Basemap.BaseLayers.Add(tiledLayer);

     };
}
catch (Exception e)
{
     Log.Error(e, e.Message);
     await DialogService.DisplayAlertAsync("Not Connected", "No connection exists so basemap will not be loaded", "Ok");
}

 

It seems to me the API should provide a way to know that a layer timed out trying to load.  Am I just missing something?  

 

Thanks

-Joe

Outcomes