<?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 Unable to call sequential commands together in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13835786#M85848</link>
    <description>&lt;P&gt;I have the below code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; [CommandMethod(nameof(ConsecutiveCommand))]
 public void ConsecutiveCommand()
 {
     Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument
         .Editor.Command("_AeccAddNetworkPipeTable");
     Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument
         .Editor.Command("_AeccAddNetworkStructTable");
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the first command to finish executing before execute the second one. But then, it seems that only the first one is executed but not the second one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both of the commands involve user actions, like depending on user input to place the table. I'm not sure whether this is what causing the second command to be "overlooked".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
    <pubDate>Fri, 03 Oct 2025 10:35:28 GMT</pubDate>
    <dc:creator>soonhui</dc:creator>
    <dc:date>2025-10-03T10:35:28Z</dc:date>
    <item>
      <title>Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13835786#M85848</link>
      <description>&lt;P&gt;I have the below code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; [CommandMethod(nameof(ConsecutiveCommand))]
 public void ConsecutiveCommand()
 {
     Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument
         .Editor.Command("_AeccAddNetworkPipeTable");
     Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument
         .Editor.Command("_AeccAddNetworkStructTable");
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the first command to finish executing before execute the second one. But then, it seems that only the first one is executed but not the second one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both of the commands involve user actions, like depending on user input to place the table. I'm not sure whether this is what causing the second command to be "overlooked".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2025 10:35:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13835786#M85848</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-10-03T10:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13835928#M85849</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;What about using CommandAsync instead?&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[CommandMethod(nameof(ConsecutiveCommand))]
public static async void ConsecutiveCommand()
{
    var ed = Application.DocumentManager.MdiActiveDocument.Editor;
    await ed.CommandAsync("_AeccAddNetworkPipeTable");
    while (((string)AcCoreAp.GetSystemVariable("CMDNAMES")).Contains("AeccAddNetworkPipeTable", StringComparison.CurrentCultureIgnoreCase))
    {
        try { await ed.CommandAsync(Editor.PauseToken); }
        catch { break; }
    }
    ed.Command("_AeccAddNetworkStructTable");
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Oct 2025 12:55:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13835928#M85849</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2025-10-03T12:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13836683#M85856</link>
      <description>&lt;P&gt;So essentially if I have more commands to be called sequentially, I just need to chain the code accordingly?&lt;/P&gt;</description>
      <pubDate>Sat, 04 Oct 2025 01:17:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13836683#M85856</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-10-04T01:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13836831#M85859</link>
      <description>&lt;P&gt;Theoretically, if the invoked command requires pauses for user input, you would need to use CommandAsync with a while loop as in the example above if the number of user inputs is not fixed, or the number of pauses required if it is known, to ensure that the command is completed before calling another one.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Oct 2025 06:19:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13836831#M85859</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2025-10-04T06:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838251#M85866</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;, your solution involving CommandAsync work, but I just wonder about Command method that I use in the original thread, because I would think that it must also work, as per your comment in another forum post &lt;A href="https://www.theswamp.org/index.php?topic=49124.0" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;SPAN&gt;With the Editor.Command() method, all the 'while stuff' is implicit, and the program will wait for the command completed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But why the Command didn't work? By right it should wait for the user input and hide all the while stuff, right?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 01:49:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838251#M85866</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-10-06T01:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838524#M85867</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7472042"&gt;@soonhui&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;, your solution involving CommandAsync work, but I just wonder about Command method that I use in the original thread, because I would think that it must also work, as per your comment in another forum post &lt;A href="https://www.theswamp.org/index.php?topic=49124.0" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;SPAN&gt;With the Editor.Command() method, all the 'while stuff' is implicit, and the program will wait for the command completed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why the Command didn't work? By right it should wait for the user input and hide all the while stuff, right?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The topic of TheSwamp that you mention (more than 10 years ago) was an attempt to supplement &lt;A href="https://keanw.com/2014/03/autocad-2015-calling-commands.html" target="_blank" rel="noopener"&gt;Kean Walmsley's topic&lt;/A&gt; explaining the differences between Command (subroutine) and CommandAsync (coroutine) with my own experiences. Based on the (too few) tests I had done at the time, it seemed to me that Command could also be called incompletely. The present topic (i.e., your experience) shows that my assertion at the time was inaccurate, hence my response with a return to the theory put forward by Kean (i.e., use CommandAsync when "you don't have all the arguments to provide to the command").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, for your purpose, a more robust method might be the following:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;private static bool IsCommandActive(string cmdName) =&amp;gt;
    ((string)AcCoreAp.GetSystemVariable("CMDNAMES"))
    .Contains(cmdName, StringComparison.OrdinalIgnoreCase);

[CommandMethod(nameof(ConsecutiveCommand))]
public static async void ConsecutiveCommand()
{
    var ed = Application.DocumentManager.MdiActiveDocument.Editor;
    try
    {
        await ed.CommandAsync("_AeccAddNetworkPipeTable");
        while (IsCommandActive("AeccAddNetworkPipeTable"))
        {
            try { await ed.CommandAsync(Editor.PauseToken); }
            catch { return; }
        }
        await ed.CommandAsync("_AeccAddNetworkStructTable");
        while (IsCommandActive("AeccAddNetworkStructTable"))
        {
            try { await ed.CommandAsync(Editor.PauseToken); }
            catch { return; }
        }
    }
    catch(Autodesk.AutoCAD.Runtime.Exception ex)
    {
        ed.WriteMessage($"\nError: {ex.Message}");
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 Oct 2025 06:49:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838524#M85867</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2025-10-06T06:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838550#M85868</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it does seem that the difference in Command and CommandAsync is... what exactly? Both seem to be fire and forget...&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 07:08:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838550#M85868</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-10-06T07:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838730#M85869</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7472042"&gt;@soonhui&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it does seem that the difference in Command and CommandAsync is... what exactly? Both seem to be fire and forget...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I cannot explain it in a better English than Kean Walmsley did in &lt;A href="https://keanw.com/2014/03/autocad-2015-calling-commands.html" target="_blank" rel="noopener"&gt;this topic&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 09:27:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838730#M85869</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2025-10-06T09:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to call sequential commands together</title>
      <link>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838827#M85870</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;, my conclusion is that the Command is synchronous only in the sense that you apply it to subroutine ( still mostly command line based thing). But the moment you apply it to command that invoke UI elements like Dialog Box, it no longer applies. Agree?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 10:40:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/unable-to-call-sequential-commands-together/m-p/13838827#M85870</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-10-06T10:40:40Z</dc:date>
    </item>
  </channel>
</rss>

