Select to view content in your preferred language

Identify Timeout

3010
2
11-22-2010 07:28 AM
JasonLevine
Deactivated User
Hello,
   I have a basic IndentifyTask function that queries a layer.  I'd like to create an alert that executes when the Identify has timed out.  Right now it looks like this:
identifyTask.requestTimeout = 10;
identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));


From what I understand, this means that if the identify runs longer than 10 seconds without completing, it's considered timed out.  My users sometimes identify an area of the map that doesn't contain any layers and the identify just keeps going, and going, and going.  I'd like to display an alert that says something like, "Nothing found" once the identify has reached 10 seconds and times out.  How would I add an eventListener to fire off an alert once the requestTimeout time has been reached?

Thanks for your help,
Jason
Tags (2)
0 Kudos
2 Replies
JasonLevine
Deactivated User
So, the only EventListeners I can add to an identifyTask are: ACTIVATE, DEACTIVATE, FAULT, and EXECUTE_COMPLETE.  No timeout....


To work around this, I created a timer object that runs for 15 seconds. Then I added a TimerEvent.TIMER_COMPLETE listener that runs a function that displays an Alert when the time runs out.  I start the timer within the identify function.  If the identifyTask completes before the timer, I remove the listener.

There has to be a better way to do this though.

Any ideas?
0 Kudos
DasaPaddock
Esri Regular Contributor
There isn't a specific event thrown for timeouts, but your "myFaultFunction" should be getting called.

Here's a test case using QueryTask:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:esri="http://www.esri.com/2008/ags"
               applicationComplete="application_applicationCompleteHandler(event)">

    <fx:Script>
        <![CDATA[
            import com.esri.ags.tasks.supportClasses.Query;
            
            import mx.events.FlexEvent;
            import mx.rpc.AsyncResponder;

            protected function application_applicationCompleteHandler(event:FlexEvent):void
            {
                var query:Query = new Query();
                query.outFields = [ "*" ];
                query.returnGeometry = true;
                query.where = "1=1";
                queryTask.execute(query, new AsyncResponder(myResultFunction, myFaultFunction));
                function myResultFunction(result:Object, token:Object = null):void
                {
                    trace("myResultFunction", result);
                }
                function myFaultFunction(error:Object, token:Object = null):void
                {
                    trace("myFaultFunction", error);
                }
            }
        ]]>
    </fx:Script>

    <fx:Declarations>
        <esri:QueryTask id="queryTask"
                        disableClientCaching="true"
                        executeComplete="trace(event)"
                        fault="trace(event)"
                        requestTimeout="1"
                        url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0"
                        useAMF="false"/>
    </fx:Declarations>

</s:Application>


The output when I run this is:
myFaultFunction [RPC Fault faultString="Request timed out" faultCode="Client.Error.RequestTimeout" faultDetail="The request timeout for the sent message was reached without receiving a response from the server."]
[FaultEvent fault=[RPC Fault faultString="Request timed out" faultCode="Client.Error.RequestTimeout" faultDetail="The request timeout for the sent message was reached without receiving a response from the server."] messageId="DE381645-A591-8705-EA82-7BF0FA0045D3" type="fault" bubbles=false cancelable=true eventPhase=2]
0 Kudos