<?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 Re: Canceling an Asynchronous call in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16709#M353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There isn't a cancel method in the API, but one approach could be to use event listeners instead of responders and then you could remove the listener and it wouldn't be called. Another approach could be to keep using responders but create a class member like private var requestCancelled:Boolean that you check in your submitComplete().&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2010 15:58:11 GMT</pubDate>
    <dc:creator>DasaPaddock</dc:creator>
    <dc:date>2010-12-10T15:58:11Z</dc:date>
    <item>
      <title>Canceling an Asynchronous call</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16708#M352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey there, I was wondering how to cancel an asynchronous call? It displays the correct results that I'm looking for; however, when I click my cancel button halfway through the loading process, I don't want it to return anything after that. So far I only have a cancel button that clears the graphics from the map, but then they redisplay once the execution is complete. Is there a method I can use to prevent this? Thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if(driveTimes.length){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var params:Object = 
&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; //Async params
&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; "SDESQL_SDE_inPoints_NAD83": featureSet,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Impedance_attribute": impedanceAttr,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Default_break_values": driveTimes
&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; serviceAreaService.outSpatialReference = map.spatialReference;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; serviceAreaService.submitJob(params, new AsyncResponder(submitComplete, onFault), new AsyncResponder(submitStatus, onFault));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showMessage("loading", true);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

function submitStatus(gpStatus:JobInfo, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // showMessage(loadingLabel, true);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showMessage("Asynchronous", true);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

function submitComplete(gpResult:JobInfo, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; serviceAreaService.getResultData(gpResult.jobId, "serviceArea_shp", new AsyncResponder(submitResult, onFault));
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
function submitResult(pv:ParameterValue, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var fs:FeatureSet = pv.value as FeatureSet;&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; var symRenderer:UniqueValueRenderer = new UniqueValueRenderer();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; symRenderer.attribute = "ToBreak";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; symRenderer.defaultSymbol = fillSym3;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var symRendererInfos:Array = new Array();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; symRendererInfos.push(new UniqueValueInfo(fillSym1, numTime1.value.toString()));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; symRendererInfos.push(new UniqueValueInfo(fillSym2, numTime2.value.toString()));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; symRenderer.infos = symRendererInfos;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicsLayer.renderer = symRenderer;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicsLayer.graphicProvider = fs.features;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicsLayer.add(graphic);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.extent = getFeatureSetExtent(fs);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clearMessage();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onFault(info:Object, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showMessage(info.toString(), false);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2010 14:15:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16708#M352</guid>
      <dc:creator>CoreySchafer</dc:creator>
      <dc:date>2010-12-10T14:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Canceling an Asynchronous call</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16709#M353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There isn't a cancel method in the API, but one approach could be to use event listeners instead of responders and then you could remove the listener and it wouldn't be called. Another approach could be to keep using responders but create a class member like private var requestCancelled:Boolean that you check in your submitComplete().&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2010 15:58:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16709#M353</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2010-12-10T15:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Canceling an Asynchronous call</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16710#M354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, that seems to work great. Appreciate the help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2010 19:55:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16710#M354</guid>
      <dc:creator>CoreySchafer</dc:creator>
      <dc:date>2010-12-10T19:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Canceling an Asynchronous call</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16711#M355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dasa,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;False alarm. Thought I had it working, but not what I expected. I was wondering about your var approach requestCancelled:Boolean. Say I do make a variable like this and set it to true when a user clicks the "cancel request button". What would I do once this variable is set to true if there is no method to cancel the request? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As of now I have a map that is displaying a service area. When the user clicks clear, everything gets cleared away. However, a little time after, the data they requested gets displayed on the screen. I would just like for the request to be canceled and for the user to be able to start over from scratch. This would be useful if, for example, a user accidentally requests a serviceArea of 1000 minutes when they only meant to type 100 minutes. Is this possible? And again, thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh and PS, I can use a synchronous or an asynchronous call if one is easier to cancel than the other. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Dec 2010 18:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16711#M355</guid>
      <dc:creator>CoreySchafer</dc:creator>
      <dc:date>2010-12-13T18:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Canceling an Asynchronous call</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16712#M356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was thinking you could change your submitComplete to be like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;function submitComplete(gpResult:JobInfo, token:Object = null):void&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (!requestCancelled)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; serviceAreaService.getResultData(gpResult.jobId, "serviceArea_shp", new AsyncResponder(submitResult, onFault));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Dec 2010 19:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/canceling-an-asynchronous-call/m-p/16712#M356</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2010-12-13T19:49:04Z</dc:date>
    </item>
  </channel>
</rss>

