How to show Progress bar until file creates?

RD Design

RD Design

Feb 25 2015 4:44 AM

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))
                            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


But my issue is I cannot move above method inside

void backgroundWorker1_DoWork()

Any ideas will really be helpful

Answers (2)