Background processing in ASP.NET page

Discussion in 'ASP .Net' started by Hilmar Bunjes, Jun 4, 2008.

  1. Hi,
    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
    itself.

    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;
    thread.Start();

    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?

    Thanks,
    Hilmar
     
    Hilmar Bunjes, Jun 4, 2008
    #1
    1. Advertising

  2. Google for Asynchronous Operations in ASP.NET. This could be the starting
    point:

    http://www.beansoftware.com/asp.net-tutorials/asynchronous-execution-pattern.aspx


    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Hilmar Bunjes" <> wrote in message
    news:4846a19b$0$7545$-online.net...
    > Hi,
    > 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
    > itself.
    >
    > 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;
    > thread.Start();
    >
    > 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?
    >
    > Thanks,
    > Hilmar
     
    Eliyahu Goldin, Jun 4, 2008
    #2
    1. Advertising

  3. This article http://www.eggheadcafe.com/articles/20040916.asp may provide
    some direction on how to use an HttpModule with a Timer to do polling.
    --Peter
    "Hilmar Bunjes" <> wrote in message
    news:4846a19b$0$7545$-online.net...
    > Hi,
    > 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
    > itself.
    >
    > 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;
    > thread.Start();
    >
    > 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?
    >
    > Thanks,
    > Hilmar
     
    Peter Bromberg [C# MVP], Jun 4, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UlI=?=

    Background processing of DLL

    =?Utf-8?B?UlI=?=, Feb 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    339
    Kevin Spencer
    Feb 26, 2004
  2. Rocio
    Replies:
    0
    Views:
    13,576
    Rocio
    Oct 28, 2005
  3. Hubert Hung-Hsien Chang
    Replies:
    2
    Views:
    514
    Michael Foord
    Sep 17, 2004
  4. mason66
    Replies:
    0
    Views:
    426
    mason66
    Jul 27, 2006
  5. JWL
    Replies:
    4
    Views:
    591
    Michael Winter
    Sep 26, 2006
Loading...

Share This Page