<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic GP ExecuteAsync locks layer in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/gp-executeasync-locks-layer/m-p/1585784#M12645</link>
    <description>&lt;P&gt;I am creating layers and attributes using&amp;nbsp;Geoprocessing.ExecuteToolAsync. The workflow is as follows:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create an empty layer with&amp;nbsp;&lt;STRONG&gt;"management.CreateFeatureClass"&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Create multiple fields using &lt;STRONG&gt;"management.AddField"&lt;/STRONG&gt; in a loop.&lt;/LI&gt;&lt;/OL&gt;&lt;H3&gt;The Problem:&lt;/H3&gt;&lt;P&gt;In the loop, after the first field is created, the second and subsequent fields cannot be added. The error message is: &lt;STRONG&gt;"Table is being edited."&lt;/STRONG&gt;&lt;/P&gt;&lt;H3&gt;Additional Information:&lt;/H3&gt;&lt;P&gt;If I create the layer without adding any fields and then try to delete the table manually in the Pro UI, I encounter the same error.&lt;/P&gt;&lt;P&gt;Below is a sample of my usage of&amp;nbsp;Geoprocessing.ExecuteToolAsync:&lt;/P&gt;&lt;PRE&gt;            var args = Geoprocessing.MakeValueArray(dataset, fieldName, fieldType.ToUpper(), null, null,
                   fieldLength, fieldAlias, isNullable ? "NULABLE" : "NON_NULLABLE");
            System.Threading.CancellationTokenSource _cts = new System.Threading.CancellationTokenSource();
            var results = await Geoprocessing.ExecuteToolAsync("management.AddField", args, null, _cts.Token,
                (eventName, o) =&amp;gt;
                {
                    switch (eventName)
                    {
                        case "OnValidate":
                            if (((IGPMessage[])o).Any(it =&amp;gt; it.Type == GPMessageType.Warning))
                            {
                                _cts.Cancel();
                            }
                            break;
                        case "OnMessage":
                        case "OnProgressMessage":
                            IGPMessage[] gpMsgs = o as IGPMessage[];
                            if (gpMsgs != null)
                            {
                                // Check for any renamed warning messages.  If there is one, get the new field name 
                                // from it.
                                foreach (IGPMessage gpMsg in gpMsgs.Where(i =&amp;gt; i.Type == GPMessageType.Warning))
                                {

                                    Match renamedMsg = Regex.Match(gpMsg.Text, renameWarningPattern);
                                    if (renamedMsg != null)
                                    {
                                        string[] words = renamedMsg.Value.Split(' ');
                                        if (words.Length &amp;gt; 0)
                                        {
                                            // The last word is the new field name; strip off anything that isn't a 'word' character (e.g. strip off
                                            // any trailing '...'.  
                                            Match wordMatch = Regex.Match(words.Last(), @"(\w*)");
                                            if (wordMatch != null)
                                                newFldName = wordMatch.Value;
                                        }
                                    }
                                }
                            }
                            break;
                        case "OnProgressPos":
                            //  MessageBox.Show($"{eventName}: {o} %");
                            break;
                        default:
                            //   MessageBox.Show($"{eventName}: {o} %");
                            break;
                    }
                }, GPExecuteToolFlags.None);
            if (results.IsFailed)
                return "";
            else
                return newFldName;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Feb 2025 09:53:07 GMT</pubDate>
    <dc:creator>zhangjinzhou</dc:creator>
    <dc:date>2025-02-15T09:53:07Z</dc:date>
    <item>
      <title>GP ExecuteAsync locks layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/gp-executeasync-locks-layer/m-p/1585784#M12645</link>
      <description>&lt;P&gt;I am creating layers and attributes using&amp;nbsp;Geoprocessing.ExecuteToolAsync. The workflow is as follows:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create an empty layer with&amp;nbsp;&lt;STRONG&gt;"management.CreateFeatureClass"&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Create multiple fields using &lt;STRONG&gt;"management.AddField"&lt;/STRONG&gt; in a loop.&lt;/LI&gt;&lt;/OL&gt;&lt;H3&gt;The Problem:&lt;/H3&gt;&lt;P&gt;In the loop, after the first field is created, the second and subsequent fields cannot be added. The error message is: &lt;STRONG&gt;"Table is being edited."&lt;/STRONG&gt;&lt;/P&gt;&lt;H3&gt;Additional Information:&lt;/H3&gt;&lt;P&gt;If I create the layer without adding any fields and then try to delete the table manually in the Pro UI, I encounter the same error.&lt;/P&gt;&lt;P&gt;Below is a sample of my usage of&amp;nbsp;Geoprocessing.ExecuteToolAsync:&lt;/P&gt;&lt;PRE&gt;            var args = Geoprocessing.MakeValueArray(dataset, fieldName, fieldType.ToUpper(), null, null,
                   fieldLength, fieldAlias, isNullable ? "NULABLE" : "NON_NULLABLE");
            System.Threading.CancellationTokenSource _cts = new System.Threading.CancellationTokenSource();
            var results = await Geoprocessing.ExecuteToolAsync("management.AddField", args, null, _cts.Token,
                (eventName, o) =&amp;gt;
                {
                    switch (eventName)
                    {
                        case "OnValidate":
                            if (((IGPMessage[])o).Any(it =&amp;gt; it.Type == GPMessageType.Warning))
                            {
                                _cts.Cancel();
                            }
                            break;
                        case "OnMessage":
                        case "OnProgressMessage":
                            IGPMessage[] gpMsgs = o as IGPMessage[];
                            if (gpMsgs != null)
                            {
                                // Check for any renamed warning messages.  If there is one, get the new field name 
                                // from it.
                                foreach (IGPMessage gpMsg in gpMsgs.Where(i =&amp;gt; i.Type == GPMessageType.Warning))
                                {

                                    Match renamedMsg = Regex.Match(gpMsg.Text, renameWarningPattern);
                                    if (renamedMsg != null)
                                    {
                                        string[] words = renamedMsg.Value.Split(' ');
                                        if (words.Length &amp;gt; 0)
                                        {
                                            // The last word is the new field name; strip off anything that isn't a 'word' character (e.g. strip off
                                            // any trailing '...'.  
                                            Match wordMatch = Regex.Match(words.Last(), @"(\w*)");
                                            if (wordMatch != null)
                                                newFldName = wordMatch.Value;
                                        }
                                    }
                                }
                            }
                            break;
                        case "OnProgressPos":
                            //  MessageBox.Show($"{eventName}: {o} %");
                            break;
                        default:
                            //   MessageBox.Show($"{eventName}: {o} %");
                            break;
                    }
                }, GPExecuteToolFlags.None);
            if (results.IsFailed)
                return "";
            else
                return newFldName;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2025 09:53:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/gp-executeasync-locks-layer/m-p/1585784#M12645</guid>
      <dc:creator>zhangjinzhou</dc:creator>
      <dc:date>2025-02-15T09:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: GP ExecuteAsync locks layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/gp-executeasync-locks-layer/m-p/1585975#M12647</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;You can use&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/add-fields.htm" target="_self"&gt;&lt;STRONG&gt;management.AddFields&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;to add all fields in one call.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2025 06:31:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/gp-executeasync-locks-layer/m-p/1585975#M12647</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2025-02-17T06:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: GP ExecuteAsync locks layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/gp-executeasync-locks-layer/m-p/1586494#M12651</link>
      <description>&lt;P&gt;The Pro SDK also provides a .NET API that allows you to create new feature classes with fields.&lt;BR /&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-DDL" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-DDL&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 17:41:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/gp-executeasync-locks-layer/m-p/1586494#M12651</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2025-02-18T17:41:57Z</dc:date>
    </item>
  </channel>
</rss>

