I'm creating a WinForm application that takes a person's photo with a webcam and am trying to now create a countdown effect. I have 4 images that i would like to cycle through but this is proving quite tricky to accomplish.
I'm using a timer for the seconds, but all that's happening is the app lags a bit and then the last image shows. Does anybody know how i might accomplish this?
Here's my code:
int counter = 0;
// start the counter to swap the images
tmCountDown.Start();
while (counter < 4)
{
// holding off picture taking
}
// reset counter for timer
counter = 0;
tmCountDown.Stop();
/// <summary>
/// timer event to switch between the countdown images
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tmCountDown_Tick(object sender, EventArgs e)
{
counter++;
//MessageBox.Show("c:/vrfid/apppics/" + counter + ".jpg");
pbCountDown.Image = new Bitmap("c:/vrfid/apppics/" + counter + ".jpg");
}
You should use
counter++;
this.SuspendLayout();
pbCountDown.Image = new Bitmap("c:/vrfid/apppics/" + counter + ".jpg");
this.ResumeLayout();
I tested it and it was working, hope it helps you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With