Timer won't tick

前端 未结 7 1774
一整个雨季
一整个雨季 2020-12-10 03:31

I have a Windows.Forms.Timer in my code, that I am executing 3 times. However, the timer isn\'t calling the tick function at all.

private int co         


        
7条回答
  •  甜味超标
    2020-12-10 03:54

    If you are using Windows.Forms.Timer then should use something like following.

    //Declare Timer
    private Timer _timer= new Timer();
    
    void Loopy(int _time)
    {
    
        _timer.Interval = _time;
        _timer.Enabled = true;
        _timer.Tick += new EventHandler(timer_Elapsed);
        _timer.Start();
    }
    
    void timer_Elapsed(object sender, EventArgs e)
    {
        //Do your stuffs here
    }
    

提交回复
热议问题