Click here to Skip to main content
13,042,421 members (137,808 online)
Rate this:
Please Sign up or sign in to vote.
hi all
i have windows dot net application in which i m capturing image and displaying it in picturebox.
but after capturing i am doing some processing on that image it takes some time
now i want to show progress bar at the bottom of my form until the image is displayed.
i have used background worker also but it is not firing the event:

private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
           progressBar1.Value = e.ProgressPercentage;
           // Set the text.
           this.Text = e.ProgressPercentage.ToString();

i have also used the timer for progress bar but that time gets activated after the processing of image.

private void timer1_Tick(object sender, EventArgs e)
           progressBar1.Value = 10;

this is my function from which i want to start progress bar.

private void btnCapture_Click(object sender, EventArgs e)
//with timer
           timer1.Interval = 100;
//or with background worker
               btnLogIn.Enabled = true;
               btnLogOff.Enabled = false;
               lblErrorMsg.Text = "";
               if (txtUserName.Text != "")
                   savingPath= "C:/Inspira/SSO/SSOImage.bmp";
                   if (File.Exists(savingPath))
                   SSOComp.SSO sosObj = new SSOComp.SSO();
                   string sucessStatus = sosObj.Capture(savingPath);
                   if (File.Exists(savingPath))
                       lblErrorMsg.ForeColor = Color.Green;
                       PicBoxFinger.ImageLocation = savingPath;
                       //after this i want to stop progress bar .                    
                       lblErrorMsg.ForeColor = Color.Red;
                       lblErrorMsg.Text = "Image not Captutred.";
                   lblErrorMsg.ForeColor = Color.Red;
                   lblErrorMsg.Text = "Please Enter User Name.";

           catch (Exception ex)
               lblErrorMsg.Text = ex.Message;

and background worker code:

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
         for (int i = 1; i <= 100; i++)
             // Wait 100 milliseconds.
             // Report progress.

i want to start the progress bar on capture click till the picture is displayed in picturebox.

thank you
god bless u all..
Posted 12-Sep-12 20:32pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have you set this properties?

backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.WorkerSupportsCancellation = true;
MAU787 13-Sep-12 4:02am
yes i have added this works on any other button click which does not have any other functionality.. but with my function it starts after displaying image
sushil.mate 13-Sep-12 5:08am
put btnCapture_Click event code in backgroundWorker1_DoWork & increase your report progress of background thread in between code.

Hope this helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100