ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / Callback Method / Callback(Action<IEditContext>,MapMember) Method
The function object.
The layer or table to operate on.
Example

In This Topic
    Callback(Action<IEditContext>,MapMember) Method
    In This Topic
    Registers that the edit operation will callback into the given function in the context of an edit operation. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    action
    The function object.
    mapMember
    The layer or table to operate on.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Creating a Row
    {
      await QueuedTask.Run(() =>
      {
        string message = String.Empty;
        bool creationResult = false;
        EditOperation editOperation = new EditOperation();
    
        using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
        using (Table enterpriseTable = geodatabase.OpenDataset<Table>("LocalGovernment.GDB.piCIPCost"))
        {
          // Declare the callback here. We are not executing it .yet.
          editOperation.Callback(context =>
          {
            TableDefinition tableDefinition = enterpriseTable.GetDefinition();
            int assetNameIndex = tableDefinition.FindField("ASSETNA");
    
            using (RowBuffer rowBuffer = enterpriseTable.CreateRowBuffer())
            {
              // Either the field index or the field name can be used in the indexer.
              rowBuffer[assetNameIndex] = "wMain";
              rowBuffer["COST"] = 700;
              rowBuffer["ACTION"] = "Open Cut";
    
              // subtype value for "Abandon".
              rowBuffer[tableDefinition.GetSubtypeField()] = 3;
    
              using (Row row = enterpriseTable.CreateRow(rowBuffer))
              {
                // To Indicate that the attribute table has to be updated.
                context.Invalidate(row);
              }
            }
          }, enterpriseTable);
    
          try
          {
            creationResult = editOperation.Execute();
            if (!creationResult) message = editOperation.ErrorMessage;
          }
          catch (GeodatabaseException exObj)
          {
            message = exObj.Message;
          }
        }
    
        if (!string.IsNullOrEmpty(message))
        {
          Debug.WriteLine(message);
        }
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also