public static void Run(string[] args) { if (IsConsoleHost(args)) { var container = new BackendServiceHostContainer(typeof(T)); container.StartService(); Console.WriteLine("Hosting the following services:"); var name = container.GetHostedServiceDescription(); Console.WriteLine("Service: " + name); Console.WriteLine("Press <Enter> to close."); Console.ReadLine(); container.StopService(); } else { var servicesToRun = new ServiceBase[] { new WindowsServiceHost(typeof(T)) }; ServiceBase.Run(servicesToRun); } }
protected override void OnStop() { container.StopService(); }