Here is some simple code to demonstrate a timer.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TimerExample
{
public partial class Form1 : Form
{
private List<tuple><datetime,>> appointmentList;
private Timer timer;
public Form1()
{
InitializeComponent();
lblMessage.Text = "";
}
private void btnStart_Click(object sender, EventArgs e)
{
CreateCalendarItems();
CreateTimer();
lblMessage.Text = "Timer Started";
SetTime();
}
private void CreateCalendarItems()
{
appointmentList = new List<tuple><datetime,>>();
appointmentList.Add(new Tuple<datetime,string>(DateTime.Now.AddMinutes(1), "Budget meeting"));
appointmentList.Add(new Tuple<datetime,string>(DateTime.Now.AddMinutes(2), "Marketing meeting"));
appointmentList.Add(new Tuple<datetime,string>(DateTime.Now.AddMinutes(3), "Project Review"));
}
private void SetTime()
{
txtTime.Text = DateTime.Now.ToLocalTime().ToShortTimeString();
}
private void CreateTimer()
{
timer = new Timer();
timer.Interval = 10000;
timer.Tick += timer_Tick;
timer.Start();
}
private void timer_Tick(object sender, EventArgs e)
{
SetTime();
var appointments = appointmentList.Where(a => a.Item1 <= DateTime.Now);
if (appointments.Count() > 0)
{
string msg = "The following appointments are due:\n\r\n\r";
foreach (var item in appointments)
msg += String.Format("{0} - {1}\n\r\n\r", item.Item2, item.Item1);
MessageBox.Show(msg);
}
}
}
}</tuple></tuple>