系统Windows形成定时器参数

本文关键字:定时器 参数 Windows 系统 | 更新日期: 2023-09-27 17:50:38

如何将参数传递给System.Windows.Forms.Timer

private System.Windows.Forms.Timer timer;
timer.Interval = 1000;
timer.Tick += new EventHandler(timer_Tick);
timer.start
private void timer_Tick(object sender, EventArgs e)
{
}

如何传递对象sender的值

系统Windows形成定时器参数

简单定时器代码-当间隔时间结束时,不需要向任何发送方传递其get调用。

    Timer t = new Timer();
    t.Interval = 2000;
    timer1.Enabled = true;
    timer1.Tick += new System.EventHandler(OnTimerEvent);
//You can use Tag property of your timer as userState
    void timer1_Tick(object sender, EventArgs e)
    {
        Timer timer = (Timer)sender;
        MyState state = timer.Tag  as MyState;
        int x = state.Value;
    }

请查看此详细信息:http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingwithTimerControlinCSharp11302005054911AM/WorkingwithTimerControlinCSharp.aspx

我猜定时器类上有一个标签属性