Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement background processing for ASP.Net MVC website in a shared hosting environment?

I am developing my first web application using ASP.Net MVC, and I am in a situation where I would like a background service to process status notifications outside of the application, not unlike the reputation/badge system on stackoverflow.

What is the best way to handle something like this? Is it even possible in a shared-hosting environment like Godaddy, which I am using.

I don't need to communicate with the background worker directly, since I will be adding notification records to a database table with a column set to an "unprocessed" state. Then the worker will just scan the table on a regular schedule and processes what is ready.

Thanks for your advice.

like image 472
JimDaniel Avatar asked Feb 08 '11 23:02

JimDaniel


3 Answers

Have you tried with quartz.net? I think it may fit your needs.

like image 111
uvita Avatar answered Nov 11 '22 00:11

uvita


also take a look at this Simulate a Windows Service using ASP.NET to run scheduled jobs article.

it explains a nice way to schedule operations with no outer dependence.

The idea is to use Cache timeout to control the schedule. I've implemented it successfully on a project which required regular temp file cleaning. This cleaning is a bit heavy so we move this clean operation in a scheduled job (using the asp.net cache) to avoid having to deploy scheduled task or custom program.

like image 5
Steve B Avatar answered Nov 11 '22 00:11

Steve B


To answer whether GoDaddy will support a seperate service you need to ask them.

However there are a number of creative ways that you can "get around" this issue on shared hosting.

  1. Have a secure page that's purpose is to execute your background work. You could have scheduled task on a machine under your control that calls to this web page at set intervals.
  2. Use a variation of the Background Worker Thread answer from @safi. Your background worker thread could check to see if another is already processing and stop, so that only one instance is running at a time.
like image 3
btlog Avatar answered Nov 11 '22 00:11

btlog