views:

92

answers:

1

These two may look like they have no correlation but bear with me!

In a previous version of the software I develop/maintain there was a web app sitting on top of a web service. There was a scheduled task that run every hour called one of the web methods to carry out some tasks.

In the new architecture we now have a web application project with two class libraries for the Business Layer and Resource Access Layer.

However I still need the same functionality in this version, and I am currently trying to design a suitable solution.

I was thinking it may be an idea to have the hourly task running on a seperate thread of the web application that sleeps for an hour, wakes up and carries out the task, or would it be easier to expose some web mehtods in a similar way to the old application.

If anyone also has any good examples of ASP.NET threading I would apppreciate having a look at them

+1  A: 

The problem you could have is that the thread will be running in application pool process which may for various reasons be closed down. For example overnight with no activity the process could legitimately shutdown. This fine, any new request will simply spin a new worker process. However if you require something to run every hour this won't be happening if the pool is shutdown.

Additional the application pool may be a web garden where there are multiple processes. You then need to consider how you ensure you don't have multiple versions of this task.

Hence it would be better to continue with the scheduled task approach with posts a request to the web server to intiate the activity.

AnthonyWJones