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. the quesion about Timer:it is Started but does not run the funtion every minute?

the quesion about Timer:it is Started but does not run the funtion every minute?

Scheduled Pinned Locked Moved C#
question
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.
  • S Offline
    S Offline
    supercsharp1
    wrote on last edited by
    #1

    I hava a page,named TaskConf,there is a System.Windows.Forms.Timer timer1,and there is a funtion named SetTmier() to Start timer1 public void SetTimer() { timer1.interval = 60000; timer1.Ticked += new EventHandler(Task_refrush); timer1.Enable = true; } The funtion Task_refrush is the event funtion,which is belong to page TaskConf. In the other page login I call TaskConf Constructor,and then Start two thread to Start SetTimer and Task_refrush which ara belong to TaskConf: TaskConf tc = new TaskConf(); . . . .. ... Thread t1 =new Thread(new ThreadStart(tc.Task_refrush)); t1.Start(); Thread t2 = new Thread(new ThreadStart(tc.SetTimer)); t2.Start(); I found these two threads are all running,The code in Task_refrush and SetTimer is excuted,(TaskConf is not open,but constructed,only the page login is open),the timer1 in TaskConf is started,but why the timer1 does not run the funcion Task_refrush every minute?Why?

    M 1 Reply Last reply
    0
    • S supercsharp1

      I hava a page,named TaskConf,there is a System.Windows.Forms.Timer timer1,and there is a funtion named SetTmier() to Start timer1 public void SetTimer() { timer1.interval = 60000; timer1.Ticked += new EventHandler(Task_refrush); timer1.Enable = true; } The funtion Task_refrush is the event funtion,which is belong to page TaskConf. In the other page login I call TaskConf Constructor,and then Start two thread to Start SetTimer and Task_refrush which ara belong to TaskConf: TaskConf tc = new TaskConf(); . . . .. ... Thread t1 =new Thread(new ThreadStart(tc.Task_refrush)); t1.Start(); Thread t2 = new Thread(new ThreadStart(tc.SetTimer)); t2.Start(); I found these two threads are all running,The code in Task_refrush and SetTimer is excuted,(TaskConf is not open,but constructed,only the page login is open),the timer1 in TaskConf is started,but why the timer1 does not run the funcion Task_refrush every minute?Why?

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      supercsharp1 wrote:

      I hava a page,named TaskConf,there is a System.Windows.Forms.Timer timer1

      Are you using Windows.Forms.Timer in ASP.NET Webpage?? If you are calling the start() function of timer in constructor of the form, Tick() event of timer will get fired without showing the form... public Form3() { InitializeComponent(); timer1.Start(); }

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      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