Posted By

rtipton on 10/31/09


Tagged

timer


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


System.Timers.Timer Example


Published in: C# 






1 of the 3 types of timers in the .net framework

Expand | Embed | Plain Text
  1. using System;
  2. using System.Timers;
  3.  
  4. public class Program
  5. {
  6. private static System.Timers.Timer testTimer;
  7.  
  8. public static void Main(string[] args)
  9. {
  10. testTimer = new System.Timers.Timer(5000); // 5 seconds
  11. testTimer.Elapsed += new ElapsedEventHandler(OnTimerElapsed);
  12.  
  13. testTimer.Interval = 5000;
  14. testTimer.Enabled = true;
  15.  
  16. Console.WriteLine("Press the enter key to stop the timer");
  17. Console.ReadLine();
  18.  
  19. }
  20.  
  21. private static void OnTimerElapsed(object source, ElapsedEventArgs e)
  22. {
  23. Console.WriteLine("Timer elapsed at {0}", e.SignalTime);
  24. }
  25. }

Report this snippet 

You need to login to post a comment.

Download royalty free graphics