private static void RegisterSynDateService(WindowsServiceItemCollection timerServices) { try { const double interval = 1000; var sendTimer = new WindowsTimer("SendSynDataInterval", interval); timerServices.Add(sendTimer, typeof(SysDataToDataBase)); } catch (Exception ex) { Console.Write(ex); WriterLog(ex.ToString(), "error"); } }
static void Main(string[] args) { try { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); var timerServices = new WindowsServiceItemCollection(); RegisterSendSmsService(timerServices); RegisterSynDateService(timerServices); WindowsServiceHelper.RunServices(timerServices, WindowsServiceTimerExceptionCallBack); } catch (Exception ex) { WriterLog(ex.ToString(), "error"); } }
static void RegisterSendSmsService(WindowsServiceItemCollection timerServices) { #region 发送短信服务 try { const double interval = 1000; var sendTimer = new WindowsTimer("SendSMSInterval", interval); timerServices.Add(sendTimer, typeof(SendSmsCommand)); } catch (Exception ex) { Console.Write(ex); WriterLog(ex.ToString(), "error"); } #endregion }