I want to execute an event at a specific time
I added a timer with 800 ms , and in the timer event I compared between the set value and the current time but the problem is that the event happens more than ı time,as it is shown in the photo,due to the code the messagebox must occure 1 time, but when i execute it happens 7 or more times the code is:
private void timer2_Tick(object sender, EventArgs e)
{
DateTime date1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt16(Properties.Settings.Default.shift_1_end_hh), Convert.ToInt16(Properties.Settings.Default.shift_1_end_min), 0);
DateTime date2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
int result = DateTime.Compare(date1, date2);
if (result == 0)
{
MessageBox.Show("tttt");
}
}