Hi,
You can use Timer class. It has
Tick event which is triggered with
Interval you set.
private Timer _timer;
private int _startHour;
private int _startMin;
private int _endHour;
private int _endMin;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
_timer = new Timer();
_timer.Interval = 1000;
_timer.Tick += new EventHandler(_timer_Tick);
}
private void _timer_Tick(object sender, EventArgs e)
{
var currentTime = DateTime.Now;
if (currentTime.Hour == _startHour && currentTime.Minute == _startMin)
{
}
else if (currentTime.Hour == _endHour && currentTime.Minute == _endMin)
{
}
}
private void button1_Click(object sender, EventArgs e)
{
_timer.Enabled = true;
}
Depending on task which you want to execute you should consider runing it in thread.
I hope i helped you.