<?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 Nested and duplicate command events in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/nested-and-duplicate-command-events/m-p/9577762#M11437</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am currently developing an add-in that has two commands, one of which has a command dialog. While in the command dialog, a thread is launched that produces some value once in a while. When a new value is ready, the thread fires a CustomEvent. In the CustomEventHandler, I update a TextBoxCommandInput form the command dialog with the new value. As a result of this change of input, a new preview of my command is generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in practice, I see two issues when I execute this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) The ExecutePreviewHandler is invoked RECURSIVELY, while STILL INSIDE the CustomEventHandler. This is really surprising to me. As soon as I set the formattedText on the TextBoxCommandInput, the ExecutePreviewHandler is invoked right away. I would really have expected the event to be fired AFTER as the state might not be ready yet to proceed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) The second thing that I observed, and that is quite problematic and inexplicable, is that the ExecutePreviewHandler is invoked TWICE. Now since there might be a certain cost involved in generating the preview, there is certainly no need to do it twice for one single change of the TextBoxCommandInput.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of my debug output console proving my points :&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Custom - Enter
ExecutePreview - Enter
ExecutePreview - Exit
ExecutePreview - Enter
ExecutePreview - Exit
Custom - Exit&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are these two issues bugs ? Am I doing something wrong ? Any workarounds ? Any thoughts ?&lt;/P&gt;&lt;P&gt;Thanks a lot !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 13 Jun 2020 06:13:54 GMT</pubDate>
    <dc:creator>GillesJrBisson</dc:creator>
    <dc:date>2020-06-13T06:13:54Z</dc:date>
    <item>
      <title>Nested and duplicate command events</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/nested-and-duplicate-command-events/m-p/9577762#M11437</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am currently developing an add-in that has two commands, one of which has a command dialog. While in the command dialog, a thread is launched that produces some value once in a while. When a new value is ready, the thread fires a CustomEvent. In the CustomEventHandler, I update a TextBoxCommandInput form the command dialog with the new value. As a result of this change of input, a new preview of my command is generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in practice, I see two issues when I execute this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) The ExecutePreviewHandler is invoked RECURSIVELY, while STILL INSIDE the CustomEventHandler. This is really surprising to me. As soon as I set the formattedText on the TextBoxCommandInput, the ExecutePreviewHandler is invoked right away. I would really have expected the event to be fired AFTER as the state might not be ready yet to proceed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) The second thing that I observed, and that is quite problematic and inexplicable, is that the ExecutePreviewHandler is invoked TWICE. Now since there might be a certain cost involved in generating the preview, there is certainly no need to do it twice for one single change of the TextBoxCommandInput.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of my debug output console proving my points :&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Custom - Enter
ExecutePreview - Enter
ExecutePreview - Exit
ExecutePreview - Enter
ExecutePreview - Exit
Custom - Exit&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are these two issues bugs ? Am I doing something wrong ? Any workarounds ? Any thoughts ?&lt;/P&gt;&lt;P&gt;Thanks a lot !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 06:13:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/nested-and-duplicate-command-events/m-p/9577762#M11437</guid>
      <dc:creator>GillesJrBisson</dc:creator>
      <dc:date>2020-06-13T06:13:54Z</dc:date>
    </item>
  </channel>
</rss>

