Help with file generation

Dec 7 2007 4:24 AM
Hi i have a problem can anyone here help me please....

I  created a page that basically creates a pdf file. it loops until it reaches the maximum number of file to be generate.

When i click the button that says "Generate PDF" it should disable it self until all the file has been created.

here is how the code flow

Private void Button1_Click(object sender, EventArgs e)
{
    Button1.Enabled = False;
    for(int i=0 ; i <= max_count ; i++)
    {
    ******    CREATE PDF FILE IN A SPECIFIED FOLDER    ******
    }
    Button1.Enabled = True;
}
*THE PROBLEM
My problem is i notice a delay in creating the pdf files. when my maximum number of loop is set to 30 the loop is over while the created pdf file is only 5 or 7.
The problem is the button is already enabled that time. When i click the button while the files are being created, it will generate another set of pdf files that will cause problems in my application.

So i was hoping that you can help me prevent the button from being enabled until all the files are created no matter how long it took.

Please help...

Answers (2)