Background processing in ASP.NET page


Hilmar Bunjes

I'm working on a web application in ASP.NET 3.5 and need some help with
processing stuff in the background.

The user who visits a web page can make reservations. Each reservation
will result in a notification for the user and an involved company.
Sending the notifications can take some seconds but the user shouldn't
need to wait for the page. So the only way to handle this is AFAIK to do
some background processing that is not connected to the page processing

In the application I store all notifications that need to be sent in the
database so another process can take them from there and send them.
However I'm unsure how to realize this process. Due to the hosted
environment so there is no chance to deploy a Windows service.

The following solutions seem to be possible:
1. Create a QueueUserWorkItem that handles the process:
ThreadPool.QueueUserWorkItem(new WaitCallback(SendNotifications));

A problem seems to be that under high load the ASP.NET thread pool can
run out of processes.

2. Create a background thread that handles the process:
Thread thread = new Thread(new ThreadStart(SendNotifications));
thread.IsBackground = true;

3. Create a System.Threading.Timer in global.asax that regularly looks
(like every 5 min) for notifications to be sent and sends them.

Has anyone tips which of these solutions seems to be the best in this
case or maybe there is even another one I haven't thought of?





Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question