Guest User

Untitled

a guest
Aug 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. System.Threading.Timer not ticking on Windows Server 2003
  2. protected override void OnStart(string[] args)
  3. {
  4. int interval = Int32.Parse(ConfigurationManager.AppSettings["SleepTime"]) * 1000;
  5. TimerCallback cb = new TimerCallback(ProcessTimerEvent);
  6. QueueWorker worker = new QueueWorker();
  7. workTimer = new Timer(cb, worker, interval, 1000);
  8.  
  9. }
  10. private static void ProcessTimerEvent(object obj)
  11. {
  12. if (obj is QueueWorker)
  13. {
  14. QueueWorker qw = (QueueWorker)obj;
  15. qw.doWork();
  16. }
  17. }
  18. class QueueWorker
  19. {
  20. public void doWork()
  21. {
  22. // work happening here
  23. }
  24. }
  25.  
  26. System.Diagnostics.Debug.WriteLine("Beginning of Timer event...");
  27.  
  28. System.Diagnostics.Debug.WriteLine("End of Timer event");
Add Comment
Please, Sign In to add comment