-1
VS 2015에서 첫 번째 C# 서비스를 개발했지만 ElapsedEventHandler 메서드가 실행되지 않습니다. 나는 다음과 같은 코드가 있습니다 데이터 업데이터 내 로그 파일에 인쇄됩니다 시작VS 2015 C# - ElapsedEventHandler가 서비스에서 실행되지 않음
using System;
using System.ServiceProcess;
using System.Timers;
namespace UpdateEnvironmentService
{
public partial class Scheduler : ServiceBase
{
private Timer timer = null;
public Scheduler()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
timer = new Timer();
this.timer.Interval = Convert.ToDouble(1000); //timer intraval in milliseconds
this.timer.Elapsed += new System.Timers.ElapsedEventHandler(this.UpdateData);
timer.Enabled = true;
Library.WriteLog("Data Updater Started ");
}
private void UpdateData(object sender, EventArgs e)
{
Library.WriteLog("Got to update Data ");
}
protected override void OnStop()
{
timer.Enabled = false;
timer = null;
Library.WriteLog("Data Updater Stopped ");
}
}
}
라인을,하지만 난 데이터를 업데이트 있어보고 결국 결코 또는 이 데이터 업데이을 중단했다. 내 ElapsedEventHandler가 절대 실행되지 않는 것 같습니다. 왜 아무 생각 없어?