how to repeatly call my function in windows service

Posted by Jagan Jan under C# on 7/11/2013 | Points: 10 | Views : 860 | Status : [Member] | Replies : 2



System.Timers.Timer myTimer;
void Main()
{
myTimer = new System.Timers.Timer(10*30*1000);
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
myTimer.Start();
}
void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
myTimer.Stop();
line();
myTimer.Start();
}
protected override void OnStart(string[] args)
{
try
{
line();
}
catch
{

}
Main();
}
protected override void OnStop()
{
}
public void line()
{

// some code here
}




}


jagadeeshwaran


Responses

Posted by: aswinialuri-19361 on: 7/30/2013 [Member] Starter | Points: 25

Up
0
Down
hi
try this link it will help you for
to call a function in windows service
http://stackoverflow.com/questions/17596374/repeatedly-running-a-function-in-a-windows-service

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Jagan Jan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ssj_Kumar on: 7/30/2013 [Member] Starter | Points: 25

Up
0
Down
below link will solve your problem.
http://stackoverflow.com/questions/4253824/timer-not-calling-the-repeat-function-in-my-windows-service

Regards,
Jayakumar Selvakani

Jagan Jan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response