Processing pending events from within a longl lasting loop (because user wants to cancel a search)

Discussion in 'Javascript' started by Alexander van Meerten, Oct 12, 2003.

  1. Hello,

    I have to make an application that works on pc and apple mac.
    Therefore I am investigating if it's possible to use html/javascript.
    The database has 10000 records and is sequentially searched. This may
    take 20 seconds or so. I want the user to be able to quit the search
    and also I want the outputscreen to be updated immediately when a hit
    is found and not wait until the complete search is finished.

    The problem is that the click-event of the 'Cancel-button' is
    processed after the search is finished. Is there something like
    application.processmessages (similar to Delphi) so all pending events
    are processed?

    Thanks for helping,
    Alexander
    Alexander van Meerten, Oct 12, 2003
    #1
    1. Advertising

  2. "Alexander van Meerten" <> schreef in bericht
    news:3f89bb56$0$58713$4all.nl...
    > Hello,
    >
    > I have to make an application that works on pc and apple mac.
    > Therefore I am investigating if it's possible to use html/javascript.
    > The database has 10000 records and is sequentially searched. This may
    > take 20 seconds or so. I want the user to be able to quit the search
    > and also I want the outputscreen to be updated immediately when a hit
    > is found and not wait until the complete search is finished.
    >


    When a search of just (yes, just) 10000 records takes up as much as 20
    seconds, either a design flaw or a performance issue is really your problem.

    When the user has clicked the submit button, the cached page is already left
    and pressing the cancel button will only show the page which is generated on
    the server at that time when you are lucky. Try to fix the problems
    server-side, like limiting the number of results to, say, 10 per page,
    because client-side JavaScript cannot solve it for you...


    JW
    Janwillem Borleffs, Oct 12, 2003
    #2
    1. Advertising

  3. Hi JW,

    The application is an adressbook which will be distributed on a cd.
    The application will be totally client-based. No server involved. The search
    will be done in a javascript array.
    So there will be no submit. The users fills in the query values in frame1
    and presses the 'Search' button. Than there is a loop which generates
    document.writes() with hitresults in frame2. I want these results to be
    displays immediately and also that the users is able to abort the loop.
    Esspecially when there are a lot of hits and the array is large (>10000)
    this may take more time than the user is willing to wait.

    Alexander

    "Janwillem Borleffs" <> schreef in bericht
    news:3f89c1f4$0$64201$...
    >
    > "Alexander van Meerten" <> schreef in bericht
    > news:3f89bb56$0$58713$4all.nl...
    > > Hello,
    > >
    > > I have to make an application that works on pc and apple mac.
    > > Therefore I am investigating if it's possible to use html/javascript.
    > > The database has 10000 records and is sequentially searched. This may
    > > take 20 seconds or so. I want the user to be able to quit the search
    > > and also I want the outputscreen to be updated immediately when a hit
    > > is found and not wait until the complete search is finished.
    > >

    >
    > When a search of just (yes, just) 10000 records takes up as much as 20
    > seconds, either a design flaw or a performance issue is really your

    problem.
    >
    > When the user has clicked the submit button, the cached page is already

    left
    > and pressing the cancel button will only show the page which is generated

    on
    > the server at that time when you are lucky. Try to fix the problems
    > server-side, like limiting the number of results to, say, 10 per page,
    > because client-side JavaScript cannot solve it for you...
    >
    >
    > JW
    >
    >
    >
    Alexander van Meerten, Oct 12, 2003
    #3
  4. "Alexander van Meerten" <> schreef in bericht
    news:3f89d1a0$0$58704$4all.nl...
    > Hi JW,
    >
    > The application is an adressbook which will be distributed on a cd.
    > The application will be totally client-based. No server involved. The

    search
    > will be done in a javascript array.


    In that case, you will have to resort to some kind of multitasking, which is
    provided by the setTimeout() function.

    I have prepared a basic implementation at the following URL:

    http://www.jwscripts.com/playground/search2/


    HTH,
    JW
    Janwillem Borleffs, Oct 14, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve M
    Replies:
    5
    Views:
    560
    Yan-Hong Huang[MSFT]
    Jul 31, 2003
  2. Abby Lee
    Replies:
    5
    Views:
    398
    Abby Lee
    Aug 2, 2004
  3. Neil Shadrach

    Breaking out of loop if nothing pending

    Neil Shadrach, Nov 7, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    91
    Anno Siegel
    Nov 7, 2003
  4. Isaac Won
    Replies:
    9
    Views:
    371
    Ulrich Eckhardt
    Mar 4, 2013
  5. Skip Montanaro
    Replies:
    0
    Views:
    81
    Skip Montanaro
    Oct 11, 2013
Loading...

Share This Page