ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Framework Namespace / OperationManager Class / UndoAsync Method / UndoAsync(Int32,String) Method
The number of operations to roll back.
The category of operations to roll back.
Example

In This Topic
    UndoAsync(Int32,String) Method
    In This Topic
    Rolls back the specified number of operations belonging to the specified category.
    Syntax
    Public Overloads Function UndoAsync( _
       ByVal count As Integer, _
       ByVal category As String _
    ) As Task
    public Task UndoAsync( 
       int count,
       string category
    )

    Parameters

    count
    The number of operations to roll back.
    category
    The category of operations to roll back.

    Return Value

    A task that represents the work queued to execute in the ThreadPool.
    Example
    Undo/Redo Edit Operations
    // Executes an edit operation and demonstrates how to undo the operation programmatically.
    await QueuedTask.Run(() =>
    {
      var editOp = new EditOperation
      {
        Name = "My Name"
      };
      if (!editOp.IsEmpty)
      {
        //Execute and ExecuteAsync will return true if the operation was successful and false if not
        var result = editOp.Execute();
        if (result == true)
        {
          // If the operation was successful, you can undo it
          editOp.UndoAsync();
        }
      }
    });
    Undo/Redo the Most Recent Operation
    // Demonstrates how to undo and redo the most recent operation using the map's operation manager.
      //undo
      if (activeMap.OperationManager.CanUndo)
        activeMap.OperationManager?.UndoAsync();//await as needed
    
      //redo
      if (MapView.Active.Map.OperationManager.CanRedo)
        activeMap.OperationManager?.RedoAsync();//await as needed
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also