ArcGIS Pro 3.7 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 Sub Refresh() 
    public void 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();
      //Check if the MCT is required for Refresh()
      if (contentItem.IsMainThreadRequired)
      {
        // Note: Needs QueuedTask to 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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also