I have created a C# Windows service but it fails to start. I get the following message when I attempt to start it:
The System Usage Monitor service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service.
The following is my OnStart override …
/// <summary>
/// OnStart(): Put startup code here
/// - Start threads, get inital data, etc.
/// </summary>
protected override void OnStart(string[] args)
{
base.OnStart(args);
broadcaster = new UdpBroadcaster(IP_Address, Port);
itm = new IdleTimeMonitor(1 * 1 * 3000, 1000);
aam = new ActiveApplicationMonitor(1000);
itm.IdleTimeExceeded += new IdleTimeExceededDelegate(itm_IdleTimeExceeded);
itm.IdleTimeReset += new IdleTimeResetDelegate(itm_IdleTimeReset);
itm.IdleTimeEvaluated += new IdleTimeEvaluatedDelegate(itm_IdleTimeEvaluated);
aam.StartedUsingApplication += new StartedUsingApplicationDelegate(aam_StartedUsingApplication);
aam.EndedUsingApplication += new EndedUsingApplicationDelegate(aam_EndedUsingApplication);
aam.ApplicationEvaluated += new ApplicationEvaluatedDelegate(aam_ApplicationEvaluated);
}
Do I need to block at the end of that function or something? Why wont my service start?
Take a look in the event log, if your service is starting then crashing for some reason there will be an exception event in the Application Log.