using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Ashworth.WindowService.GradeDataFeed { public partial class GradeDataFeedService : ServiceBase { private readonly System.Timers.Timer _timer; GradeDataFeedManager gradeDataFeedManager; //Thread managerThread = null; public GradeDataFeedService() { InitializeComponent(); _timer = new System.Timers.Timer(); _timer.Elapsed += timer_Elapsed; } protected override void OnStart(string[] args) { _timer.Interval = 60 * 1000; _timer.Enabled = true; _timer.Start(); } private void timer_Elapsed(object sender, EventArgs e) { // Only create / start the manager if has been done so already // It should only all in once, since the manager object will not // be null and since the timer will be disabled after first run if (gradeDataFeedManager == null) { gradeDataFeedManager = new GradeDataFeedManager(); // Create thread for manager //managerThread = new Thread(shipmentTrackingNumberProcessorManager.Start); // Start the thread gradeDataFeedManager.Start(); // Stop timer, it only needs to run once to kick off the manager _timer.Enabled = false; } } protected override void OnStop() { if (gradeDataFeedManager != null) { gradeDataFeedManager.Stop(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)