/// <summary> /// Stop Service /// </summary> protected override void OnStop() { try { if (device != null) { device.StopService(); device = null; } EventLog.WriteEntry("Shiol Service Stopped", EventLogEntryType.Information); } catch (Exception e) { EventLog.WriteEntry("Shiol Service Stopped ERR. " + e.Message, EventLogEntryType.Error); } try { if (serviceHost != null) { serviceHost.StopService(); } EventLog.WriteEntry("Web Service Stopped", EventLogEntryType.Information); } catch (Exception e) { EventLog.WriteEntry("Web Service Stopped ERR. " + e.Message, EventLogEntryType.Error); } }
public static int Main(String[] args) { ManagerDeviceProvider managerDevice = new ManagerDeviceProvider(); managerDevice.StartService(); Console.ReadKey(); managerDevice.StopService(); return(0); }