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