<?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 QueuedTask.Busy in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/queuedtask-busy/m-p/872576#M5263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a tool that does layout for an application.&amp;nbsp;&amp;nbsp;The sketch type is a line.&amp;nbsp; For each click in the map a node is created.&amp;nbsp; This is done&amp;nbsp;in an await QueuedTask.Run(...).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the call is done in the&amp;nbsp;OnSketchModifiedAsync method (something I found in one of the samples led me to this approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I need to prevent "re-entry" meaning I don't want to create another QueuedTask until the first one is completed.&amp;nbsp;&amp;nbsp;I've observed that re-entry causes some very weird behaviors with layout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I originally tried is this (as the first code in the method):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while(QueuedTask.Busy)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; await Task.Yield();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My manager flagged the use of this questioning whether it is valid.&amp;nbsp; So I ask here, is this valid?&amp;nbsp; If not, what is the alternative?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Until I get an answer one way or the other, I have come up with an alternative.&amp;nbsp; I added a private boolean property to the tool called IsExecuting.&amp;nbsp; This is set to true just before calling await QueuedTask.Run(...).&amp;nbsp; Then immediately following that I am calling IsExecuting=false.&amp;nbsp; At the start of the method I check to see if it is true and then return true for the method.&amp;nbsp; According to the intellisense, this means the method is handled.&amp;nbsp; This seems to behave in similar fashion to the while loop.&amp;nbsp; But I feel the while loop works better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have found no snippets samples or discussion about using QueuedTask.Busy anywhere.&amp;nbsp; But&amp;nbsp;since the property is there, it must be used somewhere.&amp;nbsp; It seems how I use it with the while loop is valid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did find in the samples a check of QueuedTask.OnWorker.&amp;nbsp;&amp;nbsp;It only appears once in all the samples and I did not find any code snippets or examples in the Github wiki.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 27 Jun 2020 21:10:35 GMT</pubDate>
    <dc:creator>KrisCulin</dc:creator>
    <dc:date>2020-06-27T21:10:35Z</dc:date>
    <item>
      <title>QueuedTask.Busy</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/queuedtask-busy/m-p/872576#M5263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a tool that does layout for an application.&amp;nbsp;&amp;nbsp;The sketch type is a line.&amp;nbsp; For each click in the map a node is created.&amp;nbsp; This is done&amp;nbsp;in an await QueuedTask.Run(...).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the call is done in the&amp;nbsp;OnSketchModifiedAsync method (something I found in one of the samples led me to this approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I need to prevent "re-entry" meaning I don't want to create another QueuedTask until the first one is completed.&amp;nbsp;&amp;nbsp;I've observed that re-entry causes some very weird behaviors with layout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I originally tried is this (as the first code in the method):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while(QueuedTask.Busy)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; await Task.Yield();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My manager flagged the use of this questioning whether it is valid.&amp;nbsp; So I ask here, is this valid?&amp;nbsp; If not, what is the alternative?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Until I get an answer one way or the other, I have come up with an alternative.&amp;nbsp; I added a private boolean property to the tool called IsExecuting.&amp;nbsp; This is set to true just before calling await QueuedTask.Run(...).&amp;nbsp; Then immediately following that I am calling IsExecuting=false.&amp;nbsp; At the start of the method I check to see if it is true and then return true for the method.&amp;nbsp; According to the intellisense, this means the method is handled.&amp;nbsp; This seems to behave in similar fashion to the while loop.&amp;nbsp; But I feel the while loop works better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have found no snippets samples or discussion about using QueuedTask.Busy anywhere.&amp;nbsp; But&amp;nbsp;since the property is there, it must be used somewhere.&amp;nbsp; It seems how I use it with the while loop is valid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did find in the samples a check of QueuedTask.OnWorker.&amp;nbsp;&amp;nbsp;It only appears once in all the samples and I did not find any code snippets or examples in the Github wiki.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Jun 2020 21:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/queuedtask-busy/m-p/872576#M5263</guid>
      <dc:creator>KrisCulin</dc:creator>
      <dc:date>2020-06-27T21:10:35Z</dc:date>
    </item>
  </channel>
</rss>

