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;
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)
{
timer1.Start();
timer1.Interval = 100;
backgroundWorker1.RunWorkerAsync();
try
{
btnLogIn.Enabled = true;
btnLogOff.Enabled = false;
lblErrorMsg.Text = "";
if (txtUserName.Text != "")
{
savingPath= "C:/Inspira/SSO/SSOImage.bmp";
if (File.Exists(savingPath))
{
File.Delete(savingPath);
}
SSOComp.SSO sosObj = new SSOComp.SSO();
string sucessStatus = sosObj.Capture(savingPath);
if (File.Exists(savingPath))
{
lblErrorMsg.ForeColor = Color.Green;
PicBoxFinger.ImageLocation = savingPath;
}
else
{
lblErrorMsg.ForeColor = Color.Red;
lblErrorMsg.Text = "Image not Captutred.";
}
}
else
{
lblErrorMsg.ForeColor = Color.Red;
lblErrorMsg.Text = "Please Enter User Name.";
}
}
catch (Exception ex)
{
lblErrorMsg.Text = ex.Message;
}
}</pre>
and background worker code:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 1; i <= 100; i++)
{
Thread.Sleep(1000);
backgroundWorker1.ReportProgress(i+10);
}
}
i want to start the progress bar on capture click till the picture is displayed in picturebox.
thank you
god bless u all..