ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / ExecuteAsync() Method
Example

In This Topic
    ExecuteAsync() Method
    In This Topic
    Executes the Edit, modifying the database using the instructions given to the EditOperation. Returns true upon success and false upon failure.
    Syntax
    Public Function ExecuteAsync() As Task(Of Boolean)
    public Task<bool> ExecuteAsync()

    Return Value

    A task representing the EditOperation that will result in a success or failure.
    Remarks
    An EditOperation will fail execution if it detects that there are no edits that produce database changes. This can include a Modify edit that doesn't change any field values. Prior to calling ExecuteAsync you should check the IsEmpty to determine if there is work to be done.
    Example
    Edit Operation - check for actions before Execute
    // Checks for pending actions in an edit operation before attempting to execute it.
    await QueuedTask.Run(() =>
    {
      // Create an edit operation
      var op = new EditOperation() { Name = "My Edit Operation" };
      // Add some actions to the edit operation
      op.Modify(featureLayer, objectId, geometry);
      // EditOperation.Modify can unknowingly set an attribute to the already existing value
      // In this scenario the Modify action will detect that no changes are required and consequently the Execute operation will fail.
      // To avoid this, we can check if the edit operation is empty before executing it.
      if (!op.IsEmpty)
      {
        // Execute the edit operation
        var result = op.Execute();
        Debug.WriteLine($"Edit operation executed successfully: {result}");
      }
      else
      {
        Debug.WriteLine("No actions to execute in the edit operation.");
      }
    });
    Edit Operation Create Features
    // Creates new features in a feature layer using the specified geometry, attributes, or editing template.
    await QueuedTask.Run(() =>
    {
      var createFeatures = new EditOperation() { Name = "Create Features" };
      //Create a feature with a polygon
      var token = createFeatures.Create(featureLayer, polygon);
      if (createFeatures.IsSucceeded)
      {
        // token.ObjectID will be populated with the objectID of the created feature after Execute has been successful
      }
      //Do a create features and set attributes
      var attributes = new Dictionary<string, object>
    {
      { "SHAPE", polygon },
      { "NAME", "Corner Market" },
      { "SIZE", 1200.5 },
      { "DESCRIPTION", "Corner Market" }
    };
      createFeatures.Create(featureLayer, attributes);
    
      //Create features using the current template
      //Must be within a MapTool
      createFeatures.Create(currentTemplate, polygon);
    
      //Execute to execute the operation
      //Must be called within QueuedTask.Run
    
      if (!createFeatures.IsEmpty)
      {
        //Execute will return true if the operation was successful and false if not.
        createFeatures.Execute();
        //or use async flavor
        //await createFeatures.ExecuteAsync();
      }
    });
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also