So I created a function to get the MinScale and MaxScale using json (as found in a previous post). private void DynamicLayer_Initialized(object sender, EventArgs e)
{
ArcGISDynamicMapServiceLayer mapLayer = sender as ArcGISDynamicMapServiceLayer;
foreach (LayerInfo li in mapLayer.Layers)
{
if (li.SubLayerIds == null)
{
Uri layerUri = new Uri(mapLayer.Url + "/" + li.ID + "?f=json", UriKind.RelativeOrAbsolute);
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += webClient_DownloadStringCompleted;
}
}
} public void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string[] properties = e.Result.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
string minScale = properties.FirstOrDefault(p => p.Contains("minScale"));
string maxScale = properties.FirstOrDefault(p => p.Contains("maxScale"));
if (minScale != null)
minScale = minScale.Substring(minScale.IndexOf(':') + 1, minScale.Length - (minScale.IndexOf(':') + 1));
if (maxScale != null)
maxScale = maxScale.Substring(maxScale.IndexOf(':') + 1, maxScale.Length - (maxScale.IndexOf(':') + 1));
}The problem I now have is that while it is doing all of the Async calls the Initialized property of the MapService is true which triggers a Map.Layers.LayersInitialized call. I do not want to trigger this event until all of the Aysnc calls have been completed. Is there a way to achieve this?Regards,Cameron