如何使用窗口调度程序在不同的时间间隔内执行多个定时器..



如何使用窗口调度程序在不同的时间间隔内执行多个定时器。。。。?是否可以在.net中使用此功能。。。?

感谢

您也可以在不同的时间间隔使用单个计时器例如:

private void Form_Load()
{
    timer1.Interval = 1000; // 1 second
    timer1.Start(); // Start timer, This will raise Tick event after 1 second
    OnTick(); // So, call Tick event explicitly when we start timer
}
Int32 counter = 0;
private void timer1_Tick(object sender, EventArgs e)
{
    OnTick();
}
private void OnTick()
{
    if (counter % 1 == 0)
    {
        OnOneSecond();//Write your code in this method for one second
    }
    if (counter % 2 == 0)
    {
        OnTwoSecond();
    }
    counter++;
}

最新更新