Click here to Skip to main content
16,016,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...
I want to run my window service at 9:00AM to 9:00PM and after the 9:00PM my all records save to another Table only one time and last day of month all records will be deleted and last day record will be save..... please help me my window service is running at 9:00AM to 9:00PM......
Posted
Comments
Sergey Alexandrovich Kryukov 13-Jan-12 5:37am    
Re-posting won't help you. Are you kidding? I've answered your question in 37 minutes after you asked the question. Do you think we are emergency service? Do you think we are even obliged to answer? Surprise: we are not... :-)
--SA

1 solution

Of course you can add any kind of timing to your service just because you can use a timer and System.DateTime structure, see:
http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx[^],
http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx[^],
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].

However, I want to give a different advice. Don't you think you would better off using existing service which is designed to support really complex schedules? It is already bundled with Windows and enabled; you can use it on different levels. It is called Window Task Scheduler, see http://en.wikipedia.org/wiki/Windows_Task_Scheduler[^].

First, you can schedule events using command-line utilities AT.EXE or CSHTASKS.EXE (which is replacing AT.EXE), see:
http://en.wikipedia.org/wiki/At_%28Windows%29[^],
http://en.wikipedia.org/wiki/Schtasks[^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx[^].

And you also can use Window Task Scheduler API, please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383608%28v=vs.85%29.aspx[^].

To see how can you use it with .NET, see this CodeProject article: A New Task Scheduler Class Library for .NET[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900