Please remember to use "System.Timers.Timer" in Windows Service
I am implementing a Windows Service. I did a foolish mistake. I opened the design view of windows service and drag-and-drop the Timer from toolbar. Because I need the windows service to execute some code periodically. I found the timer won't triggered at all. I found that is Timer in Windows.Forms. It never works in Windows Service. You need to create a timer of System.Timers. Like the example following:
Code
System.Timers.Timer timer2 = new System.Timers.Timer(); | |
timer2.Interval = 10000; | |
timer2.Enabled = true; | |
timer2.Elapsed += new System.Timers.ElapsedEventHandler(timer2_Elapsed); |
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 183 feedbacks awaiting moderation...
Form is loading...