RD Design

RD Design

  • NA
  • 25
  • 26.7k

How to show Progress bar until file creates?

Feb 25 2015 4:44 AM
Hi,

I have a code that reads sql db and pass results to iTextsharp to generate PDF files.This part is working perfectly.I have 1000 customers and reading those customers from db and I am passing result to iTextsharp pdf writer and generate PDF files.Now I need to show a  progress bar.Tried so many ways but nothing is working well.Here is my code.

 using (SqlConnection con2 = new SqlConnection(connectionString))
                        {
                            con2.Open();
                            using (SqlCommand command2 = new SqlCommand("SELECT * FROM dbo.Customers WHERE Customer = '" + cusNo.ToString() + "'", con2))
                            using (SqlDataReader reader2 = command2.ExecuteReader())
                            {
                                int i = 0;
                                while (i <= 0)
                                {
                                //Generate PDF
                                }


                            }
                        }

When while loop starts I need to show progress bar and when all PDF file processed I need to close progress bar.Tried backgroundworker

http://www.codeproject.com/Tips/83317/BackgroundWorker-and-ProgressBar-demo

But my issue is I cannot move above method inside

void backgroundWorker1_DoWork()

Any ideas will really be helpful
Thanks


Answers (2)