ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Layer Class / SetDisplayCacheMaxAge Method
Example

In This Topic
    SetDisplayCacheMaxAge Method
    In This Topic
    Sets the duration after which the layer's display cache will be refreshed in the local storage. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetDisplayCacheMaxAge( 
       TimeSpan displayCacheAge
    )
    Public Sub SetDisplayCacheMaxAge( _
       ByVal displayCacheAge As TimeSpan _
    ) 

    Parameters

    displayCacheAge
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    Only applies when DisplayCacheType = ArcGIS.Core.CIM.DisplayCacheType.MaxAge otherwise it is ignored.
    Example
    Set the layer cache
    var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
    ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    {
      // change the layer cache type to maximum age
      //At 2.x - featureLayer.SetDisplayCacheType(ArcGIS.Core.CIM.DisplayCacheType.MaxAge);
      featureLayer.SetCacheOptions(LayerCacheType.MaxAge);
      // change from the default 5 min to 2 min
      featureLayer.SetDisplayCacheMaxAge(TimeSpan.FromMinutes(2));
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also