protected override void OnStop() { WindowsServiceLogging.WriteEventLog("******************* -- Event: OnStop -- ***********************"); WindowsServiceLogging.WriteEventLog("Attempt to Shut Down the Service"); timer.Stop(); timer = null; WindowsServiceLogging.WriteEventLog("Service Shutdown by User"); }
private void timer_tick(object sender, ElapsedEventArgs e) { WindowsServiceLogging.WriteEventLog("******************* -- Event: OnStart -- ***********************"); WindowsServiceLogging.WriteEventLog("Timer tick and operation started"); AutomatedService automatedService = new AutomatedService(); automatedService.ExecutonFunction(); WindowsServiceLogging.WriteEventLog("Operation Completed Succesfully"); WindowsServiceLogging.WriteEventLog("******************* -- Event: Completed -- ***********************"); }
protected override void OnStart(string[] args) { // System.Diagnostics.Debugger.Launch(); WindowsServiceLogging.WriteEventLog("Timer is set for one day"); WindowsServiceLogging.WriteEventLog("Service Started"); WindowsServiceLogging.WriteEventLog("*******************************************************************************************"); WindowsServiceLogging.WriteEventLog("*******************************************************************************************"); WindowsServiceLogging.WriteEventLog("*******************************************************************************************"); timer = new Timer(); this.timer.Interval = 10000; this.timer.Elapsed += new ElapsedEventHandler(this.timer_tick); this.timer.Enabled = true; }