每秒更改图片框中的图像C#

Mat*_*tBH 4 c# winforms

我正在创建一个WinForm应用程序,它使用网络摄像头拍摄一个人的照片,我正在尝试创建一个倒计时效果.我有4个图像,我想循环,但这是非常棘手的完成.

我正在使用计时器秒,但所有发生的事情是应用程序滞后一点,然后最后一张图像显示.有谁知道我怎么做到这一点?

这是我的代码:

        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");
    }
Run Code Online (Sandbox Code Playgroud)

Vam*_*msi 6

你应该用

 counter++;
 this.SuspendLayout();
 pbCountDown.Image = new Bitmap("c:/vrfid/apppics/" + counter + ".jpg");
 this.ResumeLayout();
Run Code Online (Sandbox Code Playgroud)

我测试了它并且它正在工作,希望它可以帮助你