OnTimer event doesn't be fired

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
OnTimer Event doesn't be fired.

Here is the code.

public partial class Form1 : Form
{
Appointment appointment;
ReminderSchedule remindschedule;
List<ReminderSchedule> reminderschedulelist;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
reminderschedulelist = new List<ReminderSchedule>();
remindschedule = new ReminderSchedule();
appointment = new Appointment();
appointment.ApptNo = 1;
remindschedule.Appointment = appointment;
remindschedule.Complete = false;
remindschedule.ConfirmMsg = "";
remindschedule.DailyRemindCount = 3;
remindschedule.Timer.Interval = 1000;
remindschedule.Timer.AutoReset = true;
remindschedule.Timer.Elapsed += delegate { OnRemindScheduleTimerEvent(appointment.ApptNo); };
remindschedule.Timer.Start();
reminderschedulelist.Add(remindschedule);

remindschedule = new ReminderSchedule();
appointment = new Appointment();
appointment.ApptNo = 2;
remindschedule.Appointment = appointment;
remindschedule.Complete = false;
remindschedule.ConfirmMsg = "";
remindschedule.DailyRemindCount = 3;
remindschedule.Timer.Interval = 2000;
remindschedule.Timer.AutoReset = true;
remindschedule.Timer.Elapsed += delegate { OnRemindScheduleTimerEvent(appointment.ApptNo); };
remindschedule.Timer.Start();
reminderschedulelist.Add(remindschedule);

remindschedule = new ReminderSchedule();
appointment = new Appointment();
appointment.ApptNo = 3;
remindschedule.Appointment = appointment;
remindschedule.Complete = false;
remindschedule.ConfirmMsg = "";
remindschedule.DailyRemindCount = 3;
remindschedule.Timer.Interval = 3000;
remindschedule.Timer.AutoReset = true;
remindschedule.Timer.Elapsed += delegate { OnRemindScheduleTimerEvent(appointment.ApptNo); };
remindschedule.Timer.Start();
reminderschedulelist.Add(remindschedule);


}

private void Form1_Load(object sender, EventArgs e)
{

}
public void OnRemindScheduleTimerEvent(int Index)
{
if (Index == 0)
{
this.label1.Text = System.DateTime.Now.ToLongTimeString();
}
else if (Index == 1)
{
this.label2.Text = System.DateTime.Now.ToLongTimeString();
}
else if (Index == 2)
{
this.label3.Text = System.DateTime.Now.ToLongTimeString();
}
}
}




Can anybody give me some advice?

Continue reading...
 
Back
Top