2012-08-24 41 views
0

有人可以請我提供一個關於如何在Windows服務器中使用System.Windows.Forms.Timer的例子。計時器應該每10秒'調用一次非靜態的Windows服務方法。我已(失敗)嘗試這在我的OnStart方法:Windows服務器中的System.Windows.Forms.Timer

_timer.Tick += new EventHandler(StartProcessingItems); 
_timer.Interval = 10000; 
_timer.Enabled = true; 
_timer.Start();  

這裏StartProcessingItems是我的靜態窗口服務方法。

+2

的頻率爲什麼你不能使用'系統.Timers.Timer'? – Oded

+1

[比較.NET Framework類庫中的計時器類](http://msdn.microsoft.com/zh-cn/magazine/cc164015.aspx) – Oded

+0

最好使用「System.Threading.Timer」(或'Timers.Timer')的Windows服務。 –

回答