5 Replies Latest reply on Nov 27, 2007 4:10 AM by atta707

    set runtime period

    ljonny18 Level 1
      Hi

      I am getting a runtime error:

      1502 A script has executed for longer than the default timeout period of 15 seconds.


      This is expected from my application, however I want to reduce this runtime period to 10 seconds – is this possible???? And if it is – how can I do this


      Additionally, I want to retrieve the runtime values every 5 seconds.

      My application is being refreshed every 5 seconds, and on this refresh, I want to check the current runtime values so I can perform a condition on it, e.g:

      If (runtime > 5 secons)
      {
      do something
      }

      id this also possible???

      Please let me know,

      Thanks again,

      Jon.
        • 1. Re: set runtime period
          ntsiii Level 3
          The Application has a scriptTimeoutLimit property you can set. The maximum is 60 seconds.

          Tracy
          • 2. Re: set runtime period
            ntsiii Level 3
            You can also read this property of course.
            Tracy
            • 3. Re: set runtime period
              ljonny18 Level 1
              thanks tracy, again will give it a go and let you know.

              Jon.
              • 4. Re: set runtime period
                ljonny18 Level 1
                Hi Tracy - thanks for your help.

                let me try to explain my problem further as I did not do a good jab last time.

                my application is refreshing getting data from an XML file - this process is being refreshed every 5 seconds (new data is being refreshed form the XML file):

                <mx:HTTPService
                id="myResults"
                url=" http://localhost/results.xml"
                resultFormat="e4x"
                result="resultHandler(event)" />

                //run on application startup initialisation
                private function initApp():void
                {
                myResults.send();
                }

                private function resultHandler(event:ResultEvent):void
                {
                myDataFeed = event.result as XML;

                timerPulse = new Timer(5000, 1);
                timerPulse.addEventListener(TimerEvent.TIMER, timerRefresh);
                timerPulse.start(); //start timer

                //do stuff here
                }

                private function timerRefresh(eventObj:TimerEvent):void
                {
                myResults.send();
                }

                The above is all fine!!!

                However, if I leave my application running for a very long time, I get the following error:

                1502 A script has executed for longer than the default timeout period of 15 seconds

                Although my application is very heavy.. I guess I have a memory leak somewhere in my application - however this is another problem.....

                What I want is some way to test that my application is becoming slow, and refresh it when it needs to - to prevent this error occurring.

                For example - I want to test against how long the script has been running and call a function that can refresh my application if the script has been running for longer than say 10 seconds

                Like a sort of "Panic Refresh".

                E.g.:

                if( script has executed for longer than 10 seconds )
                {
                //do panic refresh
                }

                My panic refresh will simply call a JavaScript function within my HTML embedder, so that is not a problem.

                My problem is to actually test against how long a script has been executed therefore knowing when to perform my panic refresh.

                Do you understand??? Any suggestion?

                Thanks,
                Jon.
                • 5. Re: set runtime period
                  atta707 Level 2
                  Jon,

                  Try setting the weekRef parameter to

                  timerPulse.addEventListener(TimerEvent.TIMER, timerRefresh, false, 0, true /* week ref*/);

                  This would help the garbage collector.

                  I think another -- perhaps a better approach -- would be to start the timer in the init method instead of the result handler and let it run forever.:

                  private function initApp():void
                  {
                  myResults.send();

                  timerPulse = new Timer(5000, 0);
                  timerPulse.addEventListener(TimerEvent.TIMER, timerRefresh);
                  timerPulse.start(); //start timer

                  }

                  Notice the second parameter to Timer is set to 0; that means run infinitely.

                  my rationale is that you have ONLY one timer and let it poll after every 5 seconds instead of creating a new one everytime you've your XML file from the server.

                  I hope this makes sense to you and would solve the problem!

                  ATTA