How Timer works
-
Completely new to C#. can anyone give me a big picture on how Timer works in C#? For example, what is the framework for me to do a certain job, say methodX(), every 5 seconds? thanks in advance!
-
Completely new to C#. can anyone give me a big picture on how Timer works in C#? For example, what is the framework for me to do a certain job, say methodX(), every 5 seconds? thanks in advance!
Timers are really simple to use in C#. All you have to do is declare a timer: private System.Windows.Forms.Timer timer1; or drag it onto your form. Setup the interval and add a message handler: this.timer1.Enabled = true; this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); private void timer1_Tick(object sender, System.EventArgs e) { // add your code here. right now tis fucntion will get called once every second. } Hope this helps.