Can IIS hosted WCF services perform background tasks?

933 views Asked by At

I know that probably this question would be asked to many times but... The wcf services hosted on iis7 in an asp. Net Web site can do things automatically? Like post a message to a pre-configured wall on Facebook given the permission to the application in a pre scheduled time?
For this to happen a client must send a request or it can do it alone?

1

There are 1 answers

0
Jack Ukleja On BEST ANSWER

The lifetime of a WCF service is typically determined by requests from a client i.e. if there is no client making requests then there is no service running.

Possible solutions:

  • Create a custom WCF ServiceHost, override the OnStart OnStop methods and create a background task.
  • Create an ASP.NET background task (external to WCF), which you can do with a library such as WebBackgrounder
  • Use the Windows Task Scheduler to trigger a task which polls your WCF service periodically which can then post outstanding messages to Facebook.