ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Core Namespace / Item Class / Refresh Method
Example

In This Topic
    Refresh Method (Item)
    In This Topic
    Refreshes the collection of children. Use IsMainThreadRequired to determine the correct thread for performing a refresh.
    Syntax
    public void Refresh()
    Public Sub Refresh() 
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    Certain Items must be refreshed on the MCT. Use IsMainThreadRequired to check. A true return value means the item must be refreshed on the MCT using QueuedTask.Run. SDE Items, for example, must be refreshed on the MCT. A false return value means the Item can be refreshed on any thread, including the UI, although using ArcGIS.Core.Threading.Tasks.BackgroundTask is preferred.
    Calling Refresh on the wrong thread for items where IsMainThreadRequired returns true will throw a ArcGIS.Core.CalledOnWrongThreadException.
    Example
    Refresh the child item for a folder connection Item
    var contentItem = Project.Current.GetItems<FolderConnectionProjectItem>().First();
    //var contentItem = ...
    //Check if the MCT is required for Refresh()
    if (contentItem.IsMainThreadRequired)
    {
      //QueuedTask.Run must be used if item.IsMainThreadRequired
      //returns true
      QueuedTask.Run(() => contentItem.Refresh());
    }
    else
    {
      //if item.IsMainThreadRequired returns false, any
      //thread can be used to invoke Refresh(), though
      //BackgroundTask is preferred.
      contentItem.Refresh();
    
      //Or, via BackgroundTask
      ArcGIS.Core.Threading.Tasks.BackgroundTask.Run(() =>
        contentItem.Refresh(), ArcGIS.Core.Threading.Tasks.BackgroundProgressor.None);
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also