using System; using System.ServiceProcess; using FileInterface.Scheduler; namespace FileinterfaceCronScheduler { public sealed class FileinterfaceCronSchedulerService : ServiceBase { private SchedulerRuntime _runtime; public FileinterfaceCronSchedulerService() { ServiceName = "FileinterfaceCronScheduler"; CanStop = true; CanPauseAndContinue = false; AutoLog = true; } protected override void OnStart(string[] args) { try { _runtime = RuntimeFactory.Create(); _runtime.Start(); } catch { if (_runtime != null) { _runtime.Dispose(); _runtime = null; } throw; } } protected override void OnStop() { if (_runtime != null) { _runtime.Dispose(); _runtime = null; } } } }