Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How Timer works

How Timer works

Scheduled Pinned Locked Moved C#
questioncsharptutorialcareer
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    puppiesLover
    wrote on last edited by
    #1

    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!

    M 1 Reply Last reply
    0
    • P puppiesLover

      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!

      M Offline
      M Offline
      Manster
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups