C#ProgressBar意外的步骤

Dan*_* W. 0 .net c# progress-bar

我有一个ProgressBar和一个Timer.

我想显示1小时的进度:每秒增加1/3600.

当我运行应用程序时,30分钟后,进度条大约达到100%的进度.我预计30分钟后会达到50%.这是为什么?

    public Form1()
    {
        InitializeComponent();
        this.timer1.Tick += new EventHandler(timer1_Tick);
        this.timer1.Interval = 1000;
        this.timer1.Start();
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        this.progressBar1.PerformStep();
    }
Run Code Online (Sandbox Code Playgroud)

-

        // 
        // progressBar1
        // 
        this.progressBar1.Location = new System.Drawing.Point(12, 29);
        this.progressBar1.MarqueeAnimationSpeed = 1000;
        this.progressBar1.Maximum = 3600;
        this.progressBar1.Name = "progressBar1";
        this.progressBar1.Size = new System.Drawing.Size(100, 23);
        this.progressBar1.Step = 1;
        this.progressBar1.TabIndex = 2;
Run Code Online (Sandbox Code Playgroud)

Jef*_*Son 5

您从工具箱中添加了计时器,并且已经设置了一个tick事件处理程序.这样它实际上被调用了两次.