Defendore
Defendore

Reputation: 649

How to Automate a WCF Service that does a job in regular intervals

I have a WCF Service that does a job on a request from client. I need that WCF Service to do a preprocessing on regular intervals on a day before it can service the requests coming from client. How can i automate my wcf service so that it does the preprocessing on regular intervals?

Upvotes: 4

Views: 4079

Answers (3)

Thomas Jenkins
Thomas Jenkins

Reputation: 11

MSDN Magazine: ASP.NET Combine Web and Windows Services to Run Your ASP.NET Code at Scheduled Intervals By: Andrew Needleman

http://msdn.microsoft.com/en-us/magazine/cc163821.aspx#S9

Upvotes: 1

Andrew Shepherd
Andrew Shepherd

Reputation: 45272

As M4N suggests, the Windows task scheduler allows you to set up tasks that can be run via the command line.

Another solution is to have the task descriptions and scheduled times stored in database tables. Have your service, upon initialization, create a timer (System.Timers.Timer or System.Threading.Timer) that triggers a callback every 60 seconds. On this callback, perform any tasks that are due to be run.

Upvotes: 1

M4N
M4N

Reputation: 96606

(On the server hosting the WCF service) setup a scheduled task that invokes a program (e.g. a simple console app) which triggers the WCF service's preprocessing.

Upvotes: 2

Related Questions