<?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 QueryTask Called Multiple Times in a Row - Only Returns on Result in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/querytask-called-multiple-times-in-a-row-only/m-p/407349#M9506</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In an effort to write reusable code, I wrote the function below that will query a feature layer (url paramater) by a polygon (poly parameter).&amp;nbsp; This way I don't need to have a separate query and actionscript block for each feature layer that I'll query.&amp;nbsp; The problem that will happen is that when the function is called multiple times in a row the second query will begin before the first one has completed because it's asynchronous.&amp;nbsp; At that point I'm not sure how to know which result is which.&amp;nbsp; I really want to avoid having to write a black of code for each specific query, but when I try to generalize it, like the example below, I'm running into the asynchonous issues.&amp;nbsp; Does any body have any ideas to handle this or a code example of a better way?&amp;nbsp; Is there a way I can understand which result is which?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chuck&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp; private function FilterAttributeTablesByPolygon(poly:Polygon, strURL:String):void
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; querytaskFeaturesByPolygon.url = strURL;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; queryFeaturesByPolygon.geometry = poly;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; querytaskFeaturesByPolygon.execute(queryFeaturesByPolygon);
&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected function querytaskFeaturesByPolygon_executeCompleteHandler(event:QueryEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; // highlight the selected features - NOT DONE
&amp;nbsp;&amp;nbsp;&amp;nbsp; var fs:FeatureSet = event.featureSet;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var attributes:Array = fs.attributes;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var al:ArrayList = new ArrayList();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for each (var objRec in attributes)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; al.addItem(objRec);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //code continues....
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Jan 2013 13:05:05 GMT</pubDate>
    <dc:creator>chuckfrank</dc:creator>
    <dc:date>2013-01-09T13:05:05Z</dc:date>
    <item>
      <title>QueryTask Called Multiple Times in a Row - Only Returns on Result</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/querytask-called-multiple-times-in-a-row-only/m-p/407349#M9506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In an effort to write reusable code, I wrote the function below that will query a feature layer (url paramater) by a polygon (poly parameter).&amp;nbsp; This way I don't need to have a separate query and actionscript block for each feature layer that I'll query.&amp;nbsp; The problem that will happen is that when the function is called multiple times in a row the second query will begin before the first one has completed because it's asynchronous.&amp;nbsp; At that point I'm not sure how to know which result is which.&amp;nbsp; I really want to avoid having to write a black of code for each specific query, but when I try to generalize it, like the example below, I'm running into the asynchonous issues.&amp;nbsp; Does any body have any ideas to handle this or a code example of a better way?&amp;nbsp; Is there a way I can understand which result is which?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chuck&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp; private function FilterAttributeTablesByPolygon(poly:Polygon, strURL:String):void
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; querytaskFeaturesByPolygon.url = strURL;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; queryFeaturesByPolygon.geometry = poly;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; querytaskFeaturesByPolygon.execute(queryFeaturesByPolygon);
&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected function querytaskFeaturesByPolygon_executeCompleteHandler(event:QueryEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; // highlight the selected features - NOT DONE
&amp;nbsp;&amp;nbsp;&amp;nbsp; var fs:FeatureSet = event.featureSet;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var attributes:Array = fs.attributes;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var al:ArrayList = new ArrayList();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for each (var objRec in attributes)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; al.addItem(objRec);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //code continues....
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 13:05:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/querytask-called-multiple-times-in-a-row-only/m-p/407349#M9506</guid>
      <dc:creator>chuckfrank</dc:creator>
      <dc:date>2013-01-09T13:05:05Z</dc:date>
    </item>
  </channel>
</rss>

