using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; using Topshelf; namespace ServiceDeamon { public class DeamonService : ServiceControl { private static Timer timer; private static int CheckInteval = Convert.ToInt32(ConfigurationManager.AppSettings["CheckInteval"]); public bool Start(HostControl hostControl) { timer = new Timer(new TimerCallback(CheckSta)); timer.Change(CheckInteval, Timeout.Infinite); return true; } public bool Stop(HostControl hostControl) { timer.Change(-1, 0); return true; } private static void CheckSta(object sta) { CheckServiceHelper.CheckStatus(); timer.Change(CheckInteval, Timeout.Infinite); } } }