相等分布事件处理程序计时器C#

相等分布事件处理程序计时器C#,c#,winforms,timer,event-handling,C#,Winforms,Timer,Event Handling,我想根据从值下拉列表中选择的值触发代码。我还想指定时间范围(下面的示例)。我想触发的代码在按钮1\u点击后,所以我想通过代码点击它 //Create the timer Timer timer = new Timer(); //set it up timer.Tick += new EventHandler(timer_Tick); timer.Interval = (1000 * 60 * 5); timer.Enabled = true; timer.

我想根据从值下拉列表中选择的值触发代码。我还想指定
时间范围
(下面的示例)。我想触发的代码在
按钮1\u点击
后,所以我想通过代码点击它

//Create the timer
Timer timer = new Timer();

//set it up
timer.Tick += new EventHandler(timer_Tick); 
timer.Interval = (1000 * 60 * 5);           
timer.Enabled = true;       
timer.Start(); 

//now do stuff
void timer_Tick(object sender, EventArgs e)
{
    //click the button using code
}
假设我从下拉列表中选择8,这意味着我想单击我的按钮8次,但是,需要根据时间范围均匀地单击按钮

因此,假设我选择:

13:00

15:00

这给了我3个小时。然后,我想将我从下拉列表中选择的数字(例如8)除以可用的小时数/分钟数


在本例中,我希望每22.5分钟单击一次按钮。

在所选的值更改上,重置计时器。停止,重置间隔,然后重新开始。在事件处理程序中,执行click方法