我希望程序在Timer中每秒执行一次,时间间隔也是设置成的1秒, 但是我却发现程序在1秒执行了3次。
把间隔改成半秒或者3秒, 都是半秒(3秒)执行3次。百思不得其解
所以想请教各位高人,为啥不是一次一次执行,而是3次一起执行
代码如下: 
private void timer1Tick(object sender, System.EventArgs e)
        {
            //画点
            t1.Enabled = false;
            gph.DrawEllipse(Pens.Black, cpt.X + (num + 1) * 40 - 1.5f, hy + sy * (maxline - d[num]) - 1.5f, 3, 3);
            gph.FillEllipse(new SolidBrush(Color.Black), cpt.X + (num + 1) * 40 - 1.5f, hy + sy * (maxline - d[num]) - 1.5f, 3, 3);
            //画数值
            gph.DrawString(d[num].ToString(), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X + (num + 1) * 40, hy + sy * (maxline - d[num])));
            //画折线
            if (num > 0)
                gph.DrawLine(Pens.Red, cpt.X + (num + 1) * 40, hy + sy * (maxline - d[num]), cpt.X + num * 40, hy + sy * (maxline - d[num - 1]));
            pictureBox1.Image = bmap;
            num++;
            if (num == 9)
            {
                t1.Stop();
                t1.Close();
            }
        }

解决方案 »

  1.   

    你把Timer里边的贴出来没多大用,调用Timer的地方也贴一下。
      

  2.   

    t1.Elapsed += new System.Timers.ElapsedEventHandler(timer1Tick);//到达时间的时候执行事件; 
                t1.AutoReset = true;//设置是执行一次(false)还是一直执行(true); 
                t1.Enabled = true;调用的我感觉很普通啊~应该没什么问题吧?
      

  3.   

    这种情况不可能的,除非你别的地方调用了timer1Tick函数
      

  4.   

    初始化的时候把timer设成不可用的,用的地方在start