looping and displaying progress with every iteration

Discussion in 'ASP .Net' started by Bruce Whitehouse, Nov 22, 2003.

  1. This should be an easy one, but I'm not sure the best way to do it.

    I've got a form, and when I click a button it starts looping through an
    array. With each iteration of the array I want it to change the status of a
    label.

    I realise that it must complete the execution of the code-behind page before
    it can update the labels, so how do I do it?

    TIA, Bruce
    Bruce Whitehouse, Nov 22, 2003
    #1
    1. Advertising

  2. Bruce Whitehouse

    Alvin Bruney Guest

    I have a couple of approaches on my website tackling this. Essentially, you
    want to create a progress bar of sorts.

    http://www.networkip.net/tidbits/splash.htm

    Regards

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Bruce Whitehouse" <bruce@REMOVE_THISallstarfun.co.uk> wrote in message
    news:#kZ$...
    > This should be an easy one, but I'm not sure the best way to do it.
    >
    > I've got a form, and when I click a button it starts looping through an
    > array. With each iteration of the array I want it to change the status of

    a
    > label.
    >
    > I realise that it must complete the execution of the code-behind page

    before
    > it can update the labels, so how do I do it?
    >
    > TIA, Bruce
    >
    >
    Alvin Bruney, Nov 22, 2003
    #2
    1. Advertising

  3. Thanks Alvin

    What I was wanting to do was loop through some code in my VB (code behind
    page). The loop is actually going through 15 or so web services (which take
    up to 2 minutes each), so on each iteration of the loop (for each
    webservice) I wanted to let the user know what the status was of each web
    service call.

    I'm about to re-write the page using an array and a datagrid. I'll be
    letting the page complete, checking for what is to happen next, execute the
    method, update label, let page reload, etc, etc.

    So I can't have the page reload every 2 seconds. Firstly because the web
    service method that I'm calling returns a true value, and I have to wait for
    it to be returned.

    Bruce



    "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com> wrote in
    message news:...
    > I have a couple of approaches on my website tackling this. Essentially,

    you
    > want to create a progress bar of sorts.
    >
    > http://www.networkip.net/tidbits/splash.htm
    >
    > Regards
    >
    > --
    >
    >
    > -----------
    > Got TidBits?
    > Get it here: www.networkip.net/tidbits
    > "Bruce Whitehouse" <bruce@REMOVE_THISallstarfun.co.uk> wrote in message
    > news:#kZ$...
    > > This should be an easy one, but I'm not sure the best way to do it.
    > >
    > > I've got a form, and when I click a button it starts looping through an
    > > array. With each iteration of the array I want it to change the status

    of
    > a
    > > label.
    > >
    > > I realise that it must complete the execution of the code-behind page

    > before
    > > it can update the labels, so how do I do it?
    > >
    > > TIA, Bruce
    > >
    > >

    >
    >
    Bruce Whitehouse, Nov 23, 2003
    #3
  4. Bruce Whitehouse

    Alvin Bruney Guest

    Understood, but you are missing something here. You will need a refresh to
    update the client with whatever happens on the server. If you don't refresh
    there is no possible way of notifying the client that you are making
    progress because your main process cannot update the client while it is
    polling the webservices.

    On each refresh you will need to read a variable which tells you the
    percentage completion, typically stored in session or viewstate. This
    variable is set by your procedure which iterates over the webservices. So
    for example, as you pass thru each webservice and you retrieve a request,
    your percentage complete becomes x/15 * 100. You set that viewstate
    variable. At this point, you force an immediate screen refresh. But your
    code moves on in the iteration. The refresh updates the client with the
    percentage completed. This algorithm persists until all the iteration is
    done.

    Alternatively, if the output of each webservice is not dependent on the next
    webservice call, I suggest you thread the application. For example, if you
    spawned five threads, each thread queries 3 webservices all done at the same
    time, you can potentially improve performance 5 fold because each thread
    will be executing at roughly the same time (more or less).

    Put another way, if you send your son to town to get the morning paper, you
    cannot have the paper until he comes back. You will be left waiting for as
    long as he takes to get the paper. On the other hand if you send him with
    his sister (threading) and periodically, his sister leaves him in town to
    come back to let you know what is happening, you receive valuable updates
    and your wait time is 'easier'.

    Regards

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Bruce Whitehouse" <bruce@REMOVE_THISallstarfun.co.uk> wrote in message
    news:#...
    > Thanks Alvin
    >
    > What I was wanting to do was loop through some code in my VB (code behind
    > page). The loop is actually going through 15 or so web services (which

    take
    > up to 2 minutes each), so on each iteration of the loop (for each
    > webservice) I wanted to let the user know what the status was of each web
    > service call.
    >
    > I'm about to re-write the page using an array and a datagrid. I'll be
    > letting the page complete, checking for what is to happen next, execute

    the
    > method, update label, let page reload, etc, etc.
    >
    > So I can't have the page reload every 2 seconds. Firstly because the web
    > service method that I'm calling returns a true value, and I have to wait

    for
    > it to be returned.
    >
    > Bruce
    >
    >
    >
    > "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com> wrote in
    > message news:...
    > > I have a couple of approaches on my website tackling this. Essentially,

    > you
    > > want to create a progress bar of sorts.
    > >
    > > http://www.networkip.net/tidbits/splash.htm
    > >
    > > Regards
    > >
    > > --
    > >
    > >
    > > -----------
    > > Got TidBits?
    > > Get it here: www.networkip.net/tidbits
    > > "Bruce Whitehouse" <bruce@REMOVE_THISallstarfun.co.uk> wrote in message
    > > news:#kZ$...
    > > > This should be an easy one, but I'm not sure the best way to do it.
    > > >
    > > > I've got a form, and when I click a button it starts looping through

    an
    > > > array. With each iteration of the array I want it to change the

    status
    > of
    > > a
    > > > label.
    > > >
    > > > I realise that it must complete the execution of the code-behind page

    > > before
    > > > it can update the labels, so how do I do it?
    > > >
    > > > TIA, Bruce
    > > >
    > > >

    > >
    > >

    >
    >
    Alvin Bruney, Nov 23, 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. Charlie Zhang
    Replies:
    3
    Views:
    1,244
    Paul Lutus
    Aug 16, 2004
  2. Mithil

    looping every few minutes

    Mithil, May 15, 2007, in forum: Java
    Replies:
    3
    Views:
    327
    Mithil
    May 18, 2007
  3. Rudi
    Replies:
    5
    Views:
    4,974
  4. kernal32

    looping every x seconds

    kernal32, Sep 10, 2003, in forum: Perl Misc
    Replies:
    7
    Views:
    119
  5. Replies:
    5
    Views:
    264
Loading...

Share This Page