using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading.Tasks; using System.Timers; namespace MultiService { public partial class MultiServiceI : ServiceBase { private string serviceName = "1"; private System.Timers.Timer deletePathTimer = null; public MultiServiceI() { InitializeComponent(); } protected override void OnStart(string[] args) { // Log that the service is running, and show what was the last to start // just to show that the "LastService" is shared between instances of // the service. Program.Log("Started MultiService I, Last Service Started = " + (Program.LastService ?? string.Empty)); Program.LastService = "MultiService I"; deletePathTimer = new System.Timers.Timer(); deletePathTimer.Interval = (60 * 1000) * 30; // 30분 마다 실행 deletePathTimer.Elapsed += Timer_Elapsed; deletePathTimer.Start(); } private void Timer_Elapsed(object sender, ElapsedEventArgs e) { try { Program.Log("Started MultiService I," + serviceName); } catch (Exception ex) { } } protected override void OnStop() { deletePathTimer.Stop(); } } }