On 6/26/15, 8:39 AM, "mark goldin" <[email protected]> wrote:

>It's getting called just once.

Well, then that would be the problem.  PseudoThread can’t magically get
the player to spin threads.  It just automates calling a callback function
over and over again to do the total work in increments.

So, for some XML like
<xml>
  <node value=“1">
  <node value=“20">
  <node value=“55">
</xml>

You might set up an object like this:
  var state:Object = { currentIndex: 0, maxIndex: 3, total: 0, nodeList:
xml.node };

And a callback:

  function addNodes(obj:Object)
  {
     if (obj.currentIndex == obj.maxIndex) return false;

     var node:XML = obj.nodeList[obj.currentIndex];
     obj.total += int(node.@value);
     obj.currentIndex++;
     return true;
  }
  

Then you should see addNodes get called 4 times and dispatch the
threadComplete at which point state will have the right total.

-Alex

>
>On Fri, Jun 26, 2015 at 10:33 AM Alex Harui <[email protected]> wrote:
>
>> What work is done in processXML?  Step through it and make sure you are
>> done quickly and it gets called many times.
>>
>> On 6/26/15, 2:04 AM, "mark goldin" <[email protected]> wrote:
>>
>> >Ok, I got it running but it still timing out.
>> >Here is some code:
>> >
>> >public function result(data:Object):void
>> >{
>> > var re:ResultEvent = ResultEvent(data);
>> >thread = new
>> >PseudoThread(UIComponent(Application.application).systemManager,
>> >processXML, re.result.resultData);
>> >}
>> >private function processXML(resultData:XMLList):void
>> >
>> >Did not change anything in PseudoThread.
>> >
>> >On Thu, Jun 25, 2015 at 3:39 PM Alex Harui <[email protected]> wrote:
>> >
>> >> In Flex 3, mx.core.Application.application from anywhere should give
>>you
>> >> access to the Application and thus its stage.
>> >>
>> >> In Flex 4, use FlexGlobals.topLevelApplication.
>> >>
>> >> -Alex
>> >>
>> >> On 6/25/15, 10:59 AM, "mark goldin" <[email protected]> wrote:
>> >>
>> >> >Alex, I need to use it from a command class that does not have
>> >> >systemManager or its stages. How do I go about it?
>> >> >
>> >> >On Thu, Jun 25, 2015 at 11:34 AM Javier Guerrero García
>> >> ><[email protected]>
>> >> >wrote:
>> >> >
>> >> >> More on that:
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> 
>>http://www.jamesward.com/2008/11/21/drunk-on-software-episode-3-performan
>> >> >>ce-pitfalls-of-flexs-arraycollection/
>> >> >>
>> >> >> On Thu, Jun 25, 2015 at 6:29 PM, Javier Guerrero García
>> >> >><[email protected]
>> >> >> >
>> >> >> wrote:
>> >> >>
>> >> >> > Hi Mark:
>> >> >> >
>> >> >> > A long shot here: are you sure that, while you are processing
>>the
>> >>XML,
>> >> >> > you're NOT triggering constant UI updates on each operation? For
>> >> >> instance:
>> >> >> > if after processing each XML item, you are adding the final
>>result
>> >>to
>> >> >>an
>> >> >> > ArrayCollection, and you have some rendering component bound to
>> >>that
>> >> >> > ArrayCollection, that could cause a total repaint of the item
>> >> >>renderers
>> >> >> FOR
>> >> >> > EACH XML ITEM processed, hence causing the timeout. Something
>> >>similar
>> >> >> > happened to me a while ago, and after noticing and solving it, I
>> >>can
>> >> >>say
>> >> >> > that 60 seconds are more than enough to process a few hundreds
>>of
>> >> >> thousand
>> >> >> > XML items, and unless your XML is REALLY huge that should be
>> >>enough :)
>> >> >> >
>> >> >> > If that applies, the obvious workaround is:
>> >> >> >
>> >> >> > 1. Do all your updates and additions on a new ArrayCollection
>>(not
>> >>on
>> >> >>the
>> >> >> > one bound to the component's dataProvider), and then just swap
>>the
>> >> >> > dataProvider of the component to point to the newly populated
>> >> >> > ArrayCollection instead
>> >> >> > 2. Or call "thefunctionthatdisabledautoupdates" in advance
>>(don't
>> >> >> remember
>> >> >> > the exact name right now) on the bound arraycollection before
>> >>starting
>> >> >> > processing your XML, modify/update your arraycollection items,
>>and
>> >> >>then
>> >> >> > enabling it afterwards.
>> >> >> >
>> >> >> > P.S. "myCollection.disableAutoUpdate(); ", that was it :)
>> >> >> >
>> >> >>
>> >> >>
>> >>
>> >>
>> 
>>http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf668
>> >> >>d2-7fe7.html
>> >> >> >
>> >> >> > P.P.S. If none of that applies.... would some kind of
>>"pagination"
>> >>on
>> >> >>the
>> >> >> > UI solve it?
>> >> >> >
>> >> >> > On Thu, Jun 25, 2015 at 3:52 PM, mark goldin
>> >><[email protected]>
>> >> >> > wrote:
>> >> >> >
>> >> >> >> I have a large xml data that UI needs to process. I am getting
>>the
>> >> >>above
>> >> >> >> message about timing out. Not sure I can break my function into
>> >> >>smaller
>> >> >> >> pieces. Any other idea?
>> >> >> >>
>> >> >> >> Thanks
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >>
>> >>
>>
>>

Reply via email to