How to do OnTimedEvent when Timer is a member of a class and consists of List<T>

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

Jeff0803

Guest
There's a class inherited from Timer class and Appointment class is declared.

public class ReminderSchedule : Timer
{
private Appointment m_appointment;
private Int16 m_daily_remind_count;
private string m_confirm_msg;
private bool m_complete;
private Timer m_timer;
public Appointment Appointment
{
get { return m_appointment; }
set
{
m_appointment = value;
}
}
public Int16 DailyRemindCount
{
get { return m_daily_remind_count; }
set
{
m_daily_remind_count = value;
}
}
public string ConfirmMsg
{
get { return m_confirm_msg; }
set
{
m_confirm_msg = value;
}
}
public bool Complete
{
get { return m_complete; }
set
{
m_complete = value;
}
}
public Timer Timer
{
get { return m_timer; }
set
{
m_timer = value;
}
}
public ReminderSchedule()
{
}
}


The Appointment class is like following.

public class Appointment
{
private Int32 m_appt_no;
private DateTime m_appt_date;
.
.
.
public Int32 ApptNo
{
get { return this.m_appt_no; }
set { this.m_appt_no = value; }
}
public DateTime ApptDate
{
get { return this.m_appt_date; }
set { this.m_appt_date = value; }
}
.
.
.
}

Here is the main part.

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 += OnTimedEvent;
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 += OnTimedEvent;
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 += OnTimedEvent;
remindschedule.Timer.Start();
reminderschedulelist.Add(remindschedule);
}

}

I commented reminderschedule.Timer.Elapsed += OnTimerEvent; because I have no idea how to make OnTimedEvent.

Can anybody make the OnTimedEvent correctly?

Continue reading...
 
Back
Top