Looking for advice
-
morning guys i have prcedure should be work indefenitly. i dont want to make a windows service. can i put infinit loop in the Application_Start and make the thread sleep for a period while(true) { MyFunction(); System.Thrading.Thread.Sleep(150000); //150000 milisecond = one day } i have alot of utility functions i dont want to copy
-
morning guys i have prcedure should be work indefenitly. i dont want to make a windows service. can i put infinit loop in the Application_Start and make the thread sleep for a period while(true) { MyFunction(); System.Thrading.Thread.Sleep(150000); //150000 milisecond = one day } i have alot of utility functions i dont want to copy
Yes you can do it... But there's a way a little bit elegant. Timer. Create a timer and call "MyFunction" on timer tick.
//Sample code using System.Threading; ... //Class level variable private Timer loTimer; //Initialization code (main, constructor...) loTimer = new Timer(new TimerCallback(Timer_Tick), this, 0, 150000); //Timer tick func private void Timer_Tick(object sender) { MyFunction(); }
Visit my blog at http://dotnetforeveryone.blogspot.com/