Windows Service that runs periodically and once a day at specific time(5am) using C# [Resolved]

Posted by Naidulaxmi under C# on 3/9/2015 | Points: 10 | Views : 5875 | Status : [Member] | Replies : 9
Dear friends,


I want run windows services(in windows services calling web service) that runs periodically and once a day at specific time(5am) using C#, without Sunday reaming days running at specific time(5am).

Could you please help me it is urgent.

Thanks,

appalanaidu


Responses

Posted by: Bandi on: 3/9/2015 [Member] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
It will trigger the service in next day after execution of today's call....


If you want to test the code for multiple runs, then enable INTERVAL code in the webconfig file and do the testing.
<?xmlversion="1.0"encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- <add key ="Mode" value ="Daily"/> -->
<add key ="Mode" value ="Interval"/>

<add key ="IntervalMinutes" value ="1"/>
<add key ="ScheduledTime" value ="18:41"/>
</appSettings>
</configuration>


NOTE: Check the log file for next run date
private void WriteToFile(string text)
{
string path = "C:\\ServiceLog.txt" ;
using (StreamWriter writer = new StreamWriter(path, true))
{
writer.WriteLine(string.Format(text, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")));
writer.Close();
}
}


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

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

Posted by: Bandi on: 3/9/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
refer
http://www.aspsnippets.com/Articles/Simple-Windows-Service-that-runs-periodically-and-once-a-day-at-specific-time-using-C-and-VBNet.aspx

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

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

Posted by: Naidulaxmi on: 3/9/2015 [Member] Starter | Points: 25

Up
0
Down
hi Bandi,

Thanks for your replay but it working one time and another day not working in the same time (5am).

Thanks,


appalanaidu

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

Posted by: Naidulaxmi on: 3/9/2015 [Member] Starter | Points: 25

Up
0
Down
hi Bandi,

Thanks for your replay but it working one time and another day not working in the same time (5am).

Thanks,


appalanaidu

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

Posted by: Naidulaxmi on: 3/9/2015 [Member] Starter | Points: 25

Up
0
Down
hi Chandu ,

Thanks for your replay but it is running in every minit.

Thanks,

appalanaidu

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

Posted by: Naidulaxmi on: 3/9/2015 [Member] Starter | Points: 25

Up
0
Down
hi chandu,

Thanks for your replay but it is running in every mint.

Thanks,

appalanaidu

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

Posted by: A2H on: 3/9/2015 [Member] [MVP] Silver | Points: 25

Up
0
Down
You could take a look at the Quartz Scheduler to schedule your windows service to run at specific time.
Check the below link
http://www.quartz-scheduler.net/

Thanks,
A2H
My Blog

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

Posted by: Bandi on: 3/10/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
If you enable Daily Mode in the webconfig file, then it will run daily (only one time), but NOT multiple times in a day...

<add key ="Mode" value ="Daily"/> 


have a look into the code so that you can understand easily. there is no problem/issue in the code...

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

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

Login to post response