I am trying to build (csharp) one webservice /WCF engine that make two actions:
-
Have one timer (thread), that will run in each 10-10 minutes, requesting some information (connecting with other server to grab some info – status) to update in one database. (This must be automatic and no human action will be available). The idea is the webservice automaticaly (10×10 minutes) update the database with the recent information status.
-
One service method that get some information from one database. (This is one simple method that gives the information when someone request it). This method will responsible to select the status info from database.
The problem is the step 1, because step 2 is very easy.
Can anyone help me, with ideas or some code, how to the step 1.
Any pattern should be used here?
Since it’s a webapp (for instance, a “WCF Service Application” project type in VS2010), you can hook into the application events.
By default that project template type doesn’t create a Global.asax, so you’ll need to “add new item” and choose “Global Application Class” (it won’t be available if you already have a Global.asax, FWIW).
Then you can just use the start and end events on the application to start and stop your timer, so something like: