<?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 ArcGIS Pro 3.3.4 QueuedTask.Run(() =&amp;gt; does not start immediately in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-3-4-queuedtask-run-gt-does-not-start/m-p/1589239#M93426</link>
    <description>&lt;P&gt;Has anyone encountered this issue and have a better work around?&lt;/P&gt;&lt;P&gt;Many of the commonly used methods in ArcGIS Pro SDK are required to be run on the 'MCT' thread. The code is wrapped in a QueuedTask.Run block and in most cases, we need to Wait for the result before continuing processing. This is often done with Task.Wait(). However, I've recently ran into a situation where Task.Wait throws an ERROR because the task has a status of&amp;nbsp;TaskStatus.&lt;STRONG&gt;WaitingForActivation. &lt;/STRONG&gt;Is this a known issue?&lt;/P&gt;&lt;P&gt;Task t1 = QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;try { //do some long running work }&lt;/P&gt;&lt;P&gt;catch (Exception eX)&amp;nbsp; &amp;nbsp;{ // handle the error }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;//code added to prevent error&lt;/P&gt;&lt;P&gt;while (t1.Status==TaskStatus.WaitingForActivation)&lt;BR /&gt;{&lt;BR /&gt;Thread.Sleep(500);&lt;BR /&gt;loopCount++;&lt;BR /&gt;&lt;EM&gt;if (loopCount &amp;gt; 22) // 11 seconds max wait time&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; }&lt;/EM&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;t1.Wait();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2025 18:48:23 GMT</pubDate>
    <dc:creator>RichardDaniels</dc:creator>
    <dc:date>2025-02-26T18:48:23Z</dc:date>
    <item>
      <title>ArcGIS Pro 3.3.4 QueuedTask.Run(() =&gt; does not start immediately</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-3-4-queuedtask-run-gt-does-not-start/m-p/1589239#M93426</link>
      <description>&lt;P&gt;Has anyone encountered this issue and have a better work around?&lt;/P&gt;&lt;P&gt;Many of the commonly used methods in ArcGIS Pro SDK are required to be run on the 'MCT' thread. The code is wrapped in a QueuedTask.Run block and in most cases, we need to Wait for the result before continuing processing. This is often done with Task.Wait(). However, I've recently ran into a situation where Task.Wait throws an ERROR because the task has a status of&amp;nbsp;TaskStatus.&lt;STRONG&gt;WaitingForActivation. &lt;/STRONG&gt;Is this a known issue?&lt;/P&gt;&lt;P&gt;Task t1 = QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;try { //do some long running work }&lt;/P&gt;&lt;P&gt;catch (Exception eX)&amp;nbsp; &amp;nbsp;{ // handle the error }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;//code added to prevent error&lt;/P&gt;&lt;P&gt;while (t1.Status==TaskStatus.WaitingForActivation)&lt;BR /&gt;{&lt;BR /&gt;Thread.Sleep(500);&lt;BR /&gt;loopCount++;&lt;BR /&gt;&lt;EM&gt;if (loopCount &amp;gt; 22) // 11 seconds max wait time&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; }&lt;/EM&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;t1.Wait();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 18:48:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-3-4-queuedtask-run-gt-does-not-start/m-p/1589239#M93426</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2025-02-26T18:48:23Z</dc:date>
    </item>
  </channel>
</rss>

