using System; using System.ServiceProcess; namespace Card_Dispenser_Service { public partial class Service1 : ServiceBase { private readonly CardManager _manager = new CardManager(); public Service1() { InitializeComponent(); this.ServiceName = "CardDispenserService"; this.CanStop = true; this.CanPauseAndContinue = false; } public void OnDebug() { OnStart(null); } protected override void OnStart(string[] args) { Utils.LogToFile("Card Dispenser Service starting..."); _manager.Start(7777); } protected override void OnStop() { Utils.LogToFile("Card Dispenser Service stopping..."); _manager.Stop(); } } }