Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.Threading.Timer not ticking on Windows Server 2003
- protected override void OnStart(string[] args)
- {
- int interval = Int32.Parse(ConfigurationManager.AppSettings["SleepTime"]) * 1000;
- TimerCallback cb = new TimerCallback(ProcessTimerEvent);
- QueueWorker worker = new QueueWorker();
- workTimer = new Timer(cb, worker, interval, 1000);
- }
- private static void ProcessTimerEvent(object obj)
- {
- if (obj is QueueWorker)
- {
- QueueWorker qw = (QueueWorker)obj;
- qw.doWork();
- }
- }
- class QueueWorker
- {
- public void doWork()
- {
- // work happening here
- }
- }
- System.Diagnostics.Debug.WriteLine("Beginning of Timer event...");
- System.Diagnostics.Debug.WriteLine("End of Timer event");
Add Comment
Please, Sign In to add comment