<?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: How to stop queryTask execution? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641898#M59924</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Maybe:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/search.php?q=task+cancel&amp;amp;showposts=0&amp;amp;s=&amp;amp;do=process&amp;amp;contenttype=vBForum_Post&amp;amp;forumchoice%5B%5D=15&amp;amp;childforums=1&amp;amp;exactname=1"&gt;http://forums.arcgis.com/search.php?q=task+cancel&amp;amp;showposts=0&amp;amp;s=&amp;amp;do=process&amp;amp;contenttype=vBForum_Post&amp;amp;forumchoice%5B%5D=15&amp;amp;childforums=1&amp;amp;exactname=1&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Nov 2012 11:44:05 GMT</pubDate>
    <dc:creator>__Rich_</dc:creator>
    <dc:date>2012-11-21T11:44:05Z</dc:date>
    <item>
      <title>How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641897#M59923</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;i've created my own identify tool with the queryTask, but i can't find a way to stop the execution of the queryTask.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to stop the execution?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function identificationTool(action,qryUE,queryTaskUE) {&amp;nbsp; alert(action);&amp;nbsp; if(action =="go")&amp;nbsp; { &amp;nbsp; dojo.connect(map, "onClick", function(evt)&amp;nbsp; &amp;nbsp; { &amp;nbsp;&amp;nbsp; console.log("Identification: click");&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //onClick event returns the evt point where the user clicked on the map. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //This is contains the mapPoint (esri.geometry.point) and the screenPoint (pixel xy where the user clicked). &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //set query geometry = to evt.mapPoint Geometry &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qryUE.geometry = evt.mapPoint;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Execute task and call showResults on completion &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTaskUE.execute(qryUE, showResults); &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&amp;nbsp; }&amp;nbsp; else&amp;nbsp; { &amp;nbsp; dojo.connect(map, "onClick", function(evt)&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;&amp;nbsp; // Here we should stop the execution of the queryTaskUE &amp;nbsp;&amp;nbsp; map.infoWindow.hide(); &amp;nbsp; });&amp;nbsp; } }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2012 11:32:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641897#M59923</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2012-11-21T11:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641898#M59924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Maybe:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/search.php?q=task+cancel&amp;amp;showposts=0&amp;amp;s=&amp;amp;do=process&amp;amp;contenttype=vBForum_Post&amp;amp;forumchoice%5B%5D=15&amp;amp;childforums=1&amp;amp;exactname=1"&gt;http://forums.arcgis.com/search.php?q=task+cancel&amp;amp;showposts=0&amp;amp;s=&amp;amp;do=process&amp;amp;contenttype=vBForum_Post&amp;amp;forumchoice%5B%5D=15&amp;amp;childforums=1&amp;amp;exactname=1&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2012 11:44:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641898#M59924</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2012-11-21T11:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641899#M59925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've tried it with your idea (queryDeferred) but it doesn't seem to work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When i call the function cancelExecute() it seems that the object queryDeferred is empty...but it's not supposed to. The queryDeferred is a global var. So why is it still empty and not working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function identificationTool(action,qryUE,queryTaskUE)
{
 console.log("identification? "+action)
 if(action == true )
 {
&amp;nbsp; dojo.connect(map, "onClick", function(evt) 
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; console.log("Identification: click");&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; qryUE.geometry = evt.mapPoint;
&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; queryDeferred = queryTaskUE.execute(qryUE);
&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; queryDeferred.then(showResults,showError);
&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; });
 }
 
 if(action == false)
 {
&amp;nbsp; cancelExecute();
 }
}

function cancelExecute() 
{
 console.log("identification queryDeferred("+queryDeferred+") to stop = "+queryDeferred.fired)
 if(queryDeferred &amp;amp;&amp;amp; (queryDeferred.fired &amp;gt; 0)) 
 {
&amp;nbsp; console.log("Identification: stop");
&amp;nbsp; queryDeferred.cancel();
 }
}

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:16:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641899#M59925</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2021-12-12T03:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641900#M59926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It is either out of scope or uninitialised.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looking at your code, it looks like there's a path through identificationTool where cancelExecute could be called before queryDeferred has been set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you got the rest of the code available?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've had a 5 minute play with this, here's a snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var def = queryTask.execute(query,
&amp;nbsp;&amp;nbsp;&amp;nbsp; function (featureSet) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("FeatureSet returned");
&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp; function (err) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Error...but can't get at the message/reason that you expected to see, unfortunately.\n\ndef.canceled (sic) = " + def.canceled);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
);
def.cancel("A reason for cancelling can be provided here",/*not strict*/false);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This won't cancel the server-side processing (if that's what you're hoping for) but it does cancel the client-side processing of any results...but not in the way that the Dojo people intended, it would seem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:16:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641900#M59926</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2021-12-12T03:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641901#M59927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;BR /&gt;Looking at your code, it looks like there's a path through identificationTool where cancelExecute could be called before queryDeferred has been set.&lt;BR /&gt;&lt;BR /&gt;Have you got the rest of the code available?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes here is the "caller" of identificationTool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function toolOnClick(map,qryUE,queryTaskUE)
{
 // IDENTIFICATION
 $('#identify').click(function () {
&amp;nbsp; if(activeTool == "identify_spot")
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; $('#identify_spot').removeClass("active_tool");
&amp;nbsp;&amp;nbsp; activeTool = "";
&amp;nbsp;&amp;nbsp; identificationTool(false,qryUE,queryTaskUE);
&amp;nbsp; }
&amp;nbsp; else
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; if(activeTool != "")
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; $('#'+activeTool).removeClass("active_tool");&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; $('#identify_spot').addClass("active_tool");
&amp;nbsp;&amp;nbsp; console.log("Identification: start");
&amp;nbsp;&amp;nbsp; identificationTool(true,qryUE,queryTaskUE);
&amp;nbsp;&amp;nbsp; activeTool = "identify_spot";
&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
}&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The function toolOnClick() is called from $(document).ready(function()); in the init function of my code. So when a user click on the identification tool the process of identification is started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried your snippet but it doesn't seem to work. It seems that the featureSet is not working and the err function is always called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function identificationTool(action,qryUE,queryTaskUE)
{
 console.log("identification? "+action)
 if(action == true )
 {
&amp;nbsp; dojo.connect(map, "onClick", function(evt) 
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; console.log("Identification: click");&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qryUE.geometry = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //queryDeferred = queryTaskUE.execute(qryUE);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var def = queryTaskUE.execute(qryUE,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function (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;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("FeatureSet returned");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showResults(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; function (err) 
&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; alert("Error...but can't get at the message/reason that you expected to see, unfortunately.\n\ndef.canceled (sic) = " + def.canceled);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; );
&amp;nbsp;&amp;nbsp; def.cancel("A reason for cancelling can be provided here",/*not strict*/false);
&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; //queryDeferred.then(showResults,showError);
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I missing to make this "work"?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:16:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641901#M59927</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2021-12-12T03:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641902#M59928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll notice that in the snippet I provided that I am always calling def.cancel() hence why the error handler function is always being invoked - it's expected behaviour.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;May I suggest that you wrap most (nearly all!) of the identify logic into a widget/module and let it handle executing/cancelling tasks, then all your UI component needs to do is delegate to the widget/module - it will be easier to maintain state within a sensible scope with this approach.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2012 12:08:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641902#M59928</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2012-11-22T12:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641903#M59929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes I understand, but what I want to do is when I click on my identification button, the identification process is starting. But when the user click on the identification button again (to deactivate it --&amp;gt; when the var action == false ) I want the queryTask to be stopped/cancelled. That is where the dojo.deferrer.cancel is suppose to be working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it's not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And I can't figure out how to make it stop. In other module (like navigation toolbar) there is a method that stop the action (navToolbar.deactivate()) and this is exactly what I want to do, but with the queryTask.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;/************************************************************************************
 * �? COMPLETER
 */
function identificationTool(action,qryUE,queryTaskUE)
{
 var def;
 console.log("identification? "+action)
 if(action == true )
 {
&amp;nbsp; dojo.connect(map, "onClick", function(evt) 
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; console.log("Identification: click");&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; qryUE.geometry = evt.mapPoint;
&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; //queryDeferred = queryTaskUE.execute(qryUE);
&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; def = queryTaskUE.execute(qryUE,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function (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;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("FeatureSet returned");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showResults(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;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function (err) 
&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; alert("Error...but can't get at the message/reason that you expected to see, unfortunately.\n\ndef.canceled (sic) = " + def.canceled);
&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; });
 }
 else
 {
&amp;nbsp; // HERE WE STOP THE EXECUTION
&amp;nbsp; //cancelExecute();
&amp;nbsp; // this is not working because "def" is undefined even if I created it at the begining of the function.
&amp;nbsp; //def.cancel("A reason for cancelling can be provided here",/*not strict*/false);
 }
}

/************************************************************************************
 * �? COMPLETER
 */
function cancelExecute() 
{
 console.log("identification queryDeferred("+queryDeferred+") to stop = "+queryDeferred.fired)
 if(queryDeferred &amp;amp;&amp;amp; (queryDeferred.fired &amp;gt; 0)) 
 {
&amp;nbsp; console.log("Identification: stop");
&amp;nbsp; queryDeferred.cancel();
 }
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:16:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641903#M59929</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2021-12-12T03:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641904#M59930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;May I suggest that you wrap most (nearly all!) of the identify logic into a widget/module and let it handle executing/cancelling tasks, then all your UI component needs to do is delegate to the widget/module - it will be easier to maintain state within a sensible scope with this approach.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes I'll try this approach and I'll come back if it works or not. Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2012 12:58:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641904#M59930</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2012-11-22T12:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641905#M59931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yes I understand, but what I want to do is when I click on my identification button, the identification process is starting. But when the user click on the identification button again (to deactivate it --&amp;gt; when the var action == false ) I want the queryTask to be stopped/cancelled. That is where the dojo.deferrer.cancel is suppose to be working.&lt;BR /&gt;&lt;BR /&gt;But it's not.&lt;BR /&gt;&lt;BR /&gt;And I can't figure out how to make it stop. In other module (like navigation toolbar) there is a method that stop the action (navToolbar.deactivate()) and this is exactly what I want to do, but with the queryTask.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;/************************************************************************************
 * �? COMPLETER
 */
function identificationTool(action,qryUE,queryTaskUE)
{
 var def;
 console.log("identification? "+action)
 if(action == true )
 {
&amp;nbsp; dojo.connect(map, "onClick", function(evt) 
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; console.log("Identification: click");&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; qryUE.geometry = evt.mapPoint;
&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; //queryDeferred = queryTaskUE.execute(qryUE);
&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; def = queryTaskUE.execute(qryUE,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function (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;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("FeatureSet returned");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showResults(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;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function (err) 
&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; alert("Error...but can't get at the message/reason that you expected to see, unfortunately.\n\ndef.canceled (sic) = " + def.canceled);
&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; });
 }
 else
 {
&amp;nbsp; // HERE WE STOP THE EXECUTION
&amp;nbsp; //cancelExecute();
&amp;nbsp; // this is not working because "def" is undefined even if I created it at the begining of the function.
&amp;nbsp; //def.cancel("A reason for cancelling can be provided here",/*not strict*/false);
 }
}

/************************************************************************************
 * �? COMPLETER
 */
function cancelExecute() 
{
 console.log("identification queryDeferred("+queryDeferred+") to stop = "+queryDeferred.fired)
 if(queryDeferred &amp;amp;&amp;amp; (queryDeferred.fired &amp;gt; 0)) 
 {
&amp;nbsp; console.log("Identification: stop");
&amp;nbsp; queryDeferred.cancel();
 }
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course def will be undefined as the function is effectively reentrant, the previous invocation (and any variables in it) is out of scope.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You invoke the function on the first click, on the second click you invoke the function again, completely separately ('fresh' if you like) from the first invocation, this is expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sense?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:16:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641905#M59931</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2021-12-12T03:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641906#M59932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Of course def will be undefined as the function is effectively reentrant, the previous invocation (and any variables in it) is out of scope.&lt;BR /&gt;&lt;BR /&gt;You invoke the function on the first click, on the second click you invoke the function again, completely separately ('fresh' if you like) from the first invocation, this is expected.&lt;BR /&gt;&lt;BR /&gt;Make sense?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes you are right.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank's to you and to Mr. Eric Gosselin from ESRI Canada Tech Support, you helped me alot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mr. Gosselin suggest me to use the method dojo.disconnect()&amp;nbsp; (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/inside_events.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/inside_events.htm&lt;/A&gt;&lt;SPAN&gt;) and I had to modify my code so when I want to identify a new parcel, I need to click again on the identification button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code to do so and this is working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function toolOnClick(map,qryUE,queryTaskUE)
{
 // IDENTIFICATION
 $('#identify').click(function () 
 {
&amp;nbsp; var dojoClick=dojo.connect(map, "onClick", function(evt)&amp;nbsp; 
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; identificationTool(qryUE,queryTaskUE,dojoClick,evt);
&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
}

/************************************************************************************
 * �? COMPLETER
 */
function identificationTool(qryUE,queryTaskUE,dojoClick,evt)
{
&amp;nbsp; console.log("Identification: start");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qryUE.geometry = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def = queryTaskUE.execute(qryUE,
&amp;nbsp;&amp;nbsp; function (featureSet) 
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; showResults(featureSet);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp; function (err) 
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Error...but can't get at the message/reason that you expected to see, unfortunately.\n\ndef.canceled (sic) = " + def.canceled);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; );

&amp;nbsp; console.log("Identification: stop");
&amp;nbsp; // kill the handler
&amp;nbsp; dojo.disconnect(dojoClick);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, thank's to you all!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:17:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641906#M59932</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2021-12-12T03:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641907#M59933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm glad that you're happy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But...and I've misunderstood the solution you've been given...but I don't think I agree with it, normally you'd wouldn't have to keep clicking the identify button repeatedly in a GIS app to perform multiple serial identify requests.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, think about ArcMap - you put the application in identify mode then just keep clicking on the map as many times as you like, you don't have to re-click the identify button in the toolbar between map clicks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe I misunderstood your aim all along...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2012 18:38:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641907#M59933</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2012-11-22T18:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641908#M59934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm glad that you're happy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;But...and I've misunderstood the solution you've been given...but I don't think I agree with it, normally you'd wouldn't have to keep clicking the identify button repeatedly in a GIS app to perform multiple serial identify requests.&lt;BR /&gt;&lt;BR /&gt;For example, think about ArcMap - you put the application in identify mode then just keep clicking on the map as many times as you like, you don't have to re-click the identify button in the toolbar between map clicks.&lt;BR /&gt;&lt;BR /&gt;Maybe I misunderstood you aim all along...&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You are totally right and I think the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But, I think i still don't understand very well how dojo work to make it happen.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are still willing to help me find a way to make it work (like in ArcMap) I'll be very happy. I think the problem is where I should put the dojo.connect(map, "onClick", function(evt)....... and where i should manage the activation of the button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you&amp;nbsp; have any idea on how I should settle this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2012 19:20:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641908#M59934</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2012-11-22T19:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641909#M59935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you follow the ArcMap approach completely (you don't have to, but it's easier to explain if you're already comfortable with that) then then you could consider Identify to be a 'mode' that you put your application into.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When the mode is 'on' then map clicks trigger a task to be executed, when the mode is 'off' then map clicks do nothing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To start with you need a GUI control so that your user can tell you when they want to turn the mode on/off, a toggle button would do or perhaps a checkbox.&amp;nbsp; One additional thing to consider here is whether this mode needs to be mutually exclusive with any other functionality for example, it would be confusing to have Identify and Measure modes both 'on' at the same time - you can write some simple logic to ensure that turning one 'on' turns the other 'off'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All this control needs to do is connect/disconnect the map click to/from the appropriate handler, it does not perform the task etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would do this very simple step first, perhaps just put an alert in the handler for now so that you can see what the button and the connect/disconnect does etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once that's in place an working robustly you can move onto implementing the task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A lot of the lines of code you have already written can probably be re-used, it's just the flow/structure that needs changing, don't worry, it's not too complicated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2012 19:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641909#M59935</guid>
      <dc:creator>__Rich_</dc:creator>
      <dc:date>2012-11-22T19:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop queryTask execution?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641910#M59936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;YES!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's working like "ArcMap"!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here is my code if somebody need it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function init() { &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; $(document).ready(function()&amp;nbsp;&amp;nbsp; { &amp;nbsp; toolAction(map,qryUE,queryTaskUE);&amp;nbsp; }); }&amp;nbsp; function toolAction(map,qryUE,queryTaskUE) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&amp;nbsp; &amp;nbsp;&amp;nbsp; $("#identify_spot").bind("click", function(event) &amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp; // If it's the same tool &amp;nbsp; if( getActiveTool() == "#identify_spot" ) &amp;nbsp; { &amp;nbsp;&amp;nbsp; setActiveTool(); &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; // Clear all the graphics, but not the infoTemplate and I don't know why. &amp;nbsp;&amp;nbsp; map.graphics.clear(); &amp;nbsp;&amp;nbsp; dojo.disconnect(getDojoClick()); &amp;nbsp; } &amp;nbsp; // If it's the not same tool &amp;nbsp; else &amp;nbsp; { &amp;nbsp;&amp;nbsp; setActiveTool("#identify_spot"); &amp;nbsp;&amp;nbsp; setDojoClick(dojo.connect(map, "onClick", function(evt)&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; identificationTool(qryUE,queryTaskUE,evt); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("identification click"); &amp;nbsp;&amp;nbsp;&amp;nbsp; }) &amp;nbsp;&amp;nbsp; ); &amp;nbsp; }&amp;nbsp; }); }&amp;nbsp; var thisTool; var dojoAction;&amp;nbsp; function setActiveTool(tool) {&amp;nbsp; if(tool != null)&amp;nbsp; { &amp;nbsp; thisTool = tool; &amp;nbsp; $(thisTool).addClass("active_tool");&amp;nbsp;&amp;nbsp; }&amp;nbsp; else&amp;nbsp; { &amp;nbsp; $(thisTool).removeClass("active_tool"); &amp;nbsp; thisTool = "";&amp;nbsp;&amp;nbsp; }&amp;nbsp; console.log(thisTool+" class=active_tool")&amp;nbsp; }&amp;nbsp; function getActiveTool() {&amp;nbsp; return thisTool; }&amp;nbsp; function setDojoClick(action) {&amp;nbsp; if( action != null )&amp;nbsp; { &amp;nbsp; dojoAction = action;&amp;nbsp; }&amp;nbsp; else&amp;nbsp; { &amp;nbsp; dojoAction = "vide";&amp;nbsp; } }&amp;nbsp; function getDojoClick() {&amp;nbsp; console.log("kill");&amp;nbsp; return dojoAction; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Nov 2012 14:28:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-stop-querytask-execution/m-p/641910#M59936</guid>
      <dc:creator>YvanBérard</dc:creator>
      <dc:date>2012-11-23T14:28:00Z</dc:date>
    </item>
  </channel>
</rss>

