views:

172

answers:

6

I am into shared hosting and they do not allow me to use windows scheduler... So what are the ways of achieving scheduled tasks ie(timed mail) in asp.net... I just saw background process by Jeff Atwood blog... Is it relaible? Or any other ways of doing scheduled tasks...

Then i found quartz.net but i can't find a simple example that embeds quartz.net into an asp.net(without installing a Quartz.Net server as a standalone windows service)... Any suggestion on quartz.net...

A: 

.NET Scheduled Timer

or

Databound Schedule controls

Pranay Rana
-1 How's that going to be hosted in an ASP.NET process?
Pontus Gagge
this may help you : http://www.codeproject.com/KB/dotnet/ABTransClockArticle.aspx?msg=1990168#xx1990168xx or check update link 2
Pranay Rana
@pranay: not gonna help Pandya. A hoster who wont let you run Windows Scheduler is hardly going to approve separate Windows Services.
Pontus Gagge
+1  A: 

You could simply write an ASP.Net page that performs your task, e.g. sending the mails. Then use an online scheduling service like SetCronJob to call the URL of the page on your server on a schedule.

The downside of this very simple approach is that you are dependent on an external service.

Vinz
@Vinz can i trust it... Because my application is based on scheduled mail concept...
Pandiya Chendur
A: 

You can take idea from this and put your task in KeepAlive method. Hope! It helps.

Brij
A: 

I had this very same problem not long ago, and short of using a third party service, there are no great ways around it.

That said, I used the .NET Application Cache object with an expiry time of 24 hours.

Cache["DailyTask"] = true;

Then in my base page class, everytime a page request was made, I checked for the existing of that variable, and if existing, I ran the task. The downside of this is that then you are reliant on there being page requests made to your application.

Lastly, another way I have seen this done, is to set a callback on the cache expiry (CacheItemRemovedCallback method) and then chain that method to insert a new item into the cache which also has a callback and so the cycle repeats.

Astrofaes
+1  A: 

I was investigating Microsoft.Web.Administration assembly Schedule Class to achive same thing (http://tinyurl.com/354eauw) but it seems that class can be used only to schedule IIS worker process restart, here is the example of creating app pools and seting periodical restart: http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/add

So only way was to schedule with this was ASP.NET app restart and then in Application_Start do the scheduled work. But that is ugly hack not solution, so at the end I ended up adding scheduling capabilities to our homegrown backup windows service that was allready running on web server, so IMO Quartz.net is the best solution for you. Maybe you could convince your web provider to install Quartz.net all other solutions seems like a hack that will give you more or less problems.

Antonio Bakula
A: 

System.Timers.Timer - http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx

start it up in your global.asax

dave thieben