mirror of
https://github.com/ckaczor/SystemTemperatureStatusWindow.git
synced 2026-01-14 09:35:43 -05:00
58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using Common.Debug;
|
|
using System;
|
|
using System.ServiceModel;
|
|
using System.ServiceProcess;
|
|
using SystemTemperatureService.Framework;
|
|
|
|
namespace SystemTemperatureService
|
|
{
|
|
[WindowsService("SystemTemperatureStatus", DisplayName = "System Temperature Status", Description = "", StartMode = ServiceStartMode.Automatic, ServiceAccount = ServiceAccount.LocalSystem)]
|
|
public class ServiceImplementation : IWindowsService
|
|
{
|
|
private ServiceHost _serviceHost;
|
|
|
|
public void OnStart(string[] args)
|
|
{
|
|
using (new BeginEndTracer(GetType().Name))
|
|
{
|
|
try
|
|
{
|
|
_serviceHost = new ServiceHost(typeof(SystemTemperatureService));
|
|
_serviceHost.Open();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Tracer.WriteException("ServiceImplementation.OnStart", exception);
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnStop()
|
|
{
|
|
using (new BeginEndTracer(GetType().Name))
|
|
{
|
|
try
|
|
{
|
|
_serviceHost.Close();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Tracer.WriteException("ServiceImplementation.OnStop", exception);
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnPause() { }
|
|
|
|
public void OnContinue() { }
|
|
|
|
public void OnShutdown() { }
|
|
|
|
public void Dispose() { }
|
|
|
|
public void OnCustomCommand(int command) { }
|
|
}
|
|
}
|