Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi ,

I am new to windows service creation. I wants to create a windows service to run a procedure and ,I need to schedule job , and terminate the service after successful completion of procedure execution.please tell me how to approach it.
Thanks in advance

Regards,
sree
Posted
Comments
[no name] 16-Aug-15 15:03pm    
"how to approach it", how to approach what exactly? How to create a windows service is well documented. How to run a stored procedure from C# is also well documented. So what exactly could be the problem? And, why anyway? Doesn't sound like a job for a windows service.
F-ES Sitecore 16-Aug-15 15:19pm    
You don't schedule the service to start and stop, you might as well service the SP or an EXE or script that runs the SP. A service runs permanently and has its own scheduling built in. They normally run on a loop, sleeping and then waking up every minute or so to see if it is time to do their work. If you google for a windows service to schedule a task you'll find example code.

You don't do this in a Windows Service. A service app runs constantly and should not stop itself unless it has run into a problem it cannot recover from.

What you're talking about is a normal scheduled job on the SQL Server, or you can even write a Console application and run it from the Windows Task Scheduler.

A Windows Service is overkill for what you describe.
 
Share this answer
 
My first impression is that you take things backward.
You have already done an approach by concluding that the solution to your problem is to build a windows service.

Since it is unlikely that you need a service, I think you should explain you problem. A service is probably not the best approach.

Nota: QA may also be the wrong place to ask such questions.
 
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