Results 1 to 2 of 2

Thread: break out of a for loop?

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Posts
    150

    break out of a for loop?

    Hi,
    I am writing a performance testing tool that will call an add document method of a webservice 1000 times. (the call to the method is just inside a for loop. for(int i=0; i<1000; i++)

    if the user decides after 500 method calls that they want the process to stop (by clicking a stop button) but doesn't want to exit the whole application, what code would need to go into the stop button to cause the previous action to exit the for loop?


    My idea in pseduo code is shown below, Not sure if this is the best way of doing it though???

    thanks in advance

    -------------------------
    global flag=true;

    while(flag==true)
    {
    for(int i=0; i<1000; i++)
    {
    //call web service method
    }
    break; //so that if the for loop finishes with the stop button being clicked it will not be executed again
    }


    stop button onclick handler
    {
    flag=false;
    }
    --------------------------------
    Last edited by eakin; Jan 9th, 2007 at 04:51 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width