2009-07-27 43 views
0

在Win2k3的服務中遇到定時器的幾個問題... 基本上,創建一個服務,每X分鐘/秒,檢查某個進程以及它是否正在運行。我想通過一個計時器完成這件事最簡單的方法。Windows 2003服務和計時器問題導致滴答不被調用?

設法安裝好服務,而且好像在報告它正在啓動/停止OK。我已經使用Eventlog.WriteEntry寫入了事件日誌,並且觀察到它正在到達啓動函數,但不是定時器標記。

  EventLog.WriteEntry("SETTINGS SET"); 
      // Set our timer's interval to the value set in the settings.xml file. 
      tmrCheck.Interval = Int32.Parse(_settingChkInterval) * 1000; 
      // Enable our timer and away we go, checking away! 
      tmrCheck.Enabled = true; 
      // Set our Tick event to our Tick void 
      tmrCheck.Tick += new EventHandler(tmrCheck_Tick_1); 

回答

1

嗯,你不能在一個服務使用一個WinForm計時器。

您需要使用System.Timers.TimerSystem.Threading.Timer

相關問題