[英]Windows Service Timer Not Firing
我有一個Windows服務,其計時器不想觸發。 我有一個附加的調試器,但沒有提供有用的信息。 奇怪的是; 該服務與我構建的可按預期工作的另一服務幾乎相同。
有問題的代碼是這樣的:
public Constructor()
{
_timer.Interval += 300000;
InitializeComponent();
_timer.Enabled = true;
//_timer.Start(); <this is not actually here. just one of the things i tried
_timer.Elapsed += new ElapsedEventHandler(timer_Tick);
}
之后,我有:
private void timer_Tick(object sender, EventArgs e)
{
DoWorkHere();
}
我不明白為什么附加“ ElapsedEventHandler”不會觸發timer_Tick方法。
編輯:“ _ timer”是:
System.Timers.Timer _timer = new System.Timers.Timer();
問題在於權限。 很抱歉浪費任何人的時間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.