using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplicationtimer{ public partial class Form1 : Form { // fixed time for lectures and thier respective lecturerers to display string timethen = "9:08:00 PM"; string timethen2 = "7:08:01 PM"; string timethen3 = "7:08:02 PM"; string newtime = Convert.ToString(System.DateTime.Now); static System.Windows.Forms.Timer theTimer = new System.Windows.Forms.Timer(); static int alarmCounter = 1; static bool exitFlag = false; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void TimerEventProcessor(Object myObject, EventArgs myEventArgs) { // calling these methods every seconds alarmCounter += 1; theTimer.Enabled = true; repitdisplay(); repitdisplay2(); exitFlag = true; } private void button1_Click(object sender, EventArgs e) { theTimer.Tick += new EventHandler(TimerEventProcessor); theTimer.Interval = 100; theTimer.Start(); // Runs the timer, and raises the event while (exitFlag == false) { // Processes all the events in the queue Application.DoEvents(); } } void repitdisplay() { label2.Text = DateTime.Now.ToLongTimeString(); if ((string.Compare(timethen, newtime) == 0) || (string.Compare(timethen3, newtime) == 0) || (string.Compare(timethen2, newtime) == 0)) { // possibly to be called from the database string disp = "Cos201"; string disp1 = "Cos401"; label1.Text = disp.ToString(); label4.Text = disp1.ToString(); } } void repitdisplay2() { if ((string.Compare(timethen, newtime) != 0) || (string.Compare(timethen3, newtime) != 0) || (string.Compare(timethen2, newtime) != 0)) { // possibly to be called from the database string disp = "Mth 321"; string disp1 = "Stat 432"; label1.Text = disp.ToString(); label4.Text = disp1.ToString(); } }