using System; using System.ComponentModel; using System.Threading; using System.ServiceProcess; using InfoCenter.Agent.Helpers; namespace InfoCenter.Agent { public class AgentService : System.ServiceProcess.ServiceBase { private Container components; private Thread listenerThread; private Listener listener; public AgentService() { Logger.Debug("Service ctor"); try { InitializeComponent(); listener = new Listener(); } catch (Exception e) { Logger.Fatal(e.Message); } Logger.Debug("Service ctor complete"); } // The main entry point for the process of service static void Main() { ServiceBase[] services; Logger.Debug("Service entry point"); services = new ServiceBase[] { new AgentService() }; ServiceBase.Run(services); } private void InitializeComponent() { components = new System.ComponentModel.Container(); this.ServiceName = "InfoCenter agent"; } protected override void OnStart(string[] args) { Logger.Debug("Service OnStart"); //listener.Run = true; listenerThread = new Thread(new ThreadStart(listener.Start)); listenerThread.Start(); } protected override void OnStop() { Logger.Debug("Service OnStop"); listenerThread.Abort(); listener = null; } protected override void OnContinue() { Logger.Debug("Service OnContinue");; } protected override void OnPause() { Logger.Debug("Service OnPause"); } protected override void OnShutdown() { Logger.Debug("Service OnShutdown"); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)