How-To - Silverlight - Setting a Layer to Auto Refresh in ArcFM Silverlight

Version 4

    Solution

     

    Occasionally clients may want to have layers in their Silverlight application refresh without user intervention. An example is when they have truck location features in a layer that are added regularly, and want to refresh the layer to show the new locations every five minutes. The Silverlight application may be customized to add this behavior.

    To accomplish this, a new AutoRefresher class is added that uses a DispatcherTimer. This AutoRefresher is assigned to a layer when it is created when the Silverlight application starts. To add the AutoRefresher:

     

    1. In Microsoft Visual Studio, create a new class named AutoRefresher in your Silverlight application project.
    2. Copy and paste the code in the attached AutoRefresher.cs file into this new class, replacing the existing code.
    3. Add any missing references that may occur.
    4. In ConfigUtility.cs, change the case: "ArcGISDynamicMapServiceLayer:" section in the CreateLayer method to:

         case "ArcGISDynamicMapServiceLayer":
         ArcGISDynamicMapServiceLayer dynamicsServiceLayer =
    new ArcGISDynamicMapServiceLayer { Url = url, ProxyURL = proxyUrl };
         dynamicsServiceLayer.DisableClientCaching = true;
                        
         var refresher = new AutoRefresher { Interval = 300 };
         if (url == "
    http://<server>/ArcGIS/rest/services/Electric/MapServer")
         {
             dynamicsServiceLayer.SetValue(AutoRefresher.RefresherProperty, refresher);
         }

     

    Note that this will only work with ArcGISDynamicMapServiceLayers and that DisableClientCaching must be set to true. The refresh interval is set by the Interval value. The layer(s) to refresh are selected by checking the url value.