maephisto
maephisto

Reputation: 5182

Building and controlling a scheduled task or service from a web application

I'm building a web application that will need to import data from other database servers when it starts.

I would like to have this import done automatically at regular intervals. I would also like to be able to start and stop the import process from my web application.

What would be the best implementation for the import agent - a Windows Service? Something else?

Upvotes: 2

Views: 1277

Answers (4)

Independent
Independent

Reputation: 2987

Of what I heard this looks like a description for Microsoft Sync Framework. I have just few information about it for myself but will be pleased to see you pointed into that direction.

I'm not sure about your question because you are talking about hourly syncing. When talking web applications, there can't be a nice way to do such a task. You have to create a console app or best task would be a Windows Service Process (which are easier then it sounds)?

Sync Framework Intro
http://msdn.microsoft.com/en-us/sync/bb821992
Sync Framework Tutorial
http://alexduggleby.com/2007/12/16/sync-framework-tutorial-part-1-introduction/
Sync Framework Samples
http://archive.msdn.microsoft.com/sync

And, when I'm editing the answer with links

Nice guide to create a Windows Service (and setup) http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx
(if first time, try it on a test project before the production project)

Upvotes: 0

Marijn
Marijn

Reputation: 10557

You could create a Windows Service that uses Quartz.Net to run the scheduled tasks.

You should not run scheduled task from your web app, since you don't have any guarantee that your web app is running. You're at IIS app pool management's mercy.

You might want to look at Best way to run scheduled tasks.

Upvotes: 1

BrandonZeider
BrandonZeider

Reputation: 8152

This might be an oversimplification, but can you create a class that does all of this work using a Timer, and then in the application_start of the global.asax, create a BackgroundWorker that kicks off this process?

Your web application could then control the BackgroundWorker object, starting/stopping as necessary.

Upvotes: 0

Oded
Oded

Reputation: 498904

If your web application needs to have this data in memory, you can use the Cache class.

Set it to expire every X hours, as you need and when it expires, re-fetch the data..

Upvotes: 1

Related Questions