public partial class WinDriverService : ServiceBase{ private DatabaseHandler wthInfoDb, wthAlertDb ; private System.Timers.Timer wthInfoTimer; private System.Timers.Timer wthAlertTimer; public WinDriverService() { InitializeComponent(); wthInfoDb = new DatabaseHandler(); wthAlertDb = new DatabaseHandler(); } protected override void OnStart(string[] args) { Thread wthInfoThread = new Thread(new ThreadStart(WthInfoThread)); wthInfoThread.Start(); Thread wthAlertThread = new Thread(new ThreadStart(WthAlertThread)); wthAlertThread.Start(); } private void WthInfoThread() { double interval = wthInfoDb.PollerConfig_ObtainTimerValue("Weather Info"); interval = (interval > 0) ? interval * 60 * 1000 : 60000 * 45; //either (mins * secs/min * ms/sec) or 45 mins wthInfoTimer = new System.Timers.Timer(interval); wthInfoTimer.Elapsed += new ElapsedEventHandler(wthInfoTimer_Elapsed); wthInfoTimer.Start(); } private void WthAlertThread() { double interval = wthAlertDb.PollerConfig_ObtainTimerValue("Weather Alerts"); interval = (interval > 0) ? interval * 60 * 1000 : 60000 * 45; //either (mins * secs/min * ms/sec) or 45 mins wthAlertTimer = new System.Timers.Timer(interval); wthAlertTimer.Elapsed += new ElapsedEventHandler(wthAlertTimer_Elapsed); wthAlertTimer.Start(); } private void wthInfoTimer_Elapsed(object sender, ElapsedEventArgs e) { try { PollerWebService.PollingWebServiceSoapClient app = new global::PollerWebService.PollingWebServiceSoapClient(); app.Open(); PollerWebService.PollerEntry[] entries = app.PollWeatherInfo(); app.Close(); if (entries.Length > 0) { TimelineController tlc = new TimelineController(); tlc.ProcessNewEntries(entries); } } catch (Exception ee) { } } private void wthAlertTimer_Elapsed(object sender, ElapsedEventArgs e) { try { PollerWebService.PollingWebServiceSoapClient app = new global::PollerWebService.PollingWebServiceSoapClient(); app.Open(); PollerWebService.PollerEntry[] entries = app.PollWeatherAlerts(); app.Close(); if (entries.Length > 0) { TimelineController tlc = new TimelineController(); tlc.ProcessNewEntries(entries); } } catch (Exception ee) { } } protected override void OnStop() { wthInfoTimer.Enabled = false; wthAlertTimer.Enabled = false; }}