2 Replies Latest reply on Oct 17, 2008 11:08 AM by phpxp

    Long operations

    phpxp
      We are doing expensive calculations (parsing large XML feeds) and experience shows that the whole browser window hangs for seconds while doing that. We prepared for this by displaying an AJAX loading icon for the user but even that stops animating.

      My question is if it is possible to somehow give the focus back to the browser so that it can update the display within our large loop. I think this is possible in general low-level desktop programming but not in a browser environment.

      Do you have any ideas other than using a "timer" and doing the calculation "asynchronously"? It would be a pain to rewrite this function into smaller substeps.

      Thanks in advance!
        • 1. Re: Long operations
          anirudhs Level 2
          Hi,

          I don't think there's any other way than to make your function pseudo-threadable and execute it in parts using setTimeout (if you're doing HTML air app dev).

          Majority of javascript applications that do complex processing (take code.google.com's syntax highlighting) do it the same way. That's currently the only way to prevent the UI from blocking in a javascript application.
          • 2. Re: Long operations
            phpxp Level 1
            Thanks, I totally agree.

            FYI, I discovered that it's actually not the XML parsing that takes most of the time but database operations and function calls. Parsing an 500k XML feed seems to take less than a second on my 2 year old laptop.