Best ASP.NET Background Service Implementation

Posted by Jason N. Gaylord on Stack Overflow See other posts from Stack Overflow or by Jason N. Gaylord
Published on 2009-09-15T02:27:19Z Indexed on 2010/04/20 18:43 UTC
Read the original article Hit count: 245

What's the best implementation for more than one background service in an ASP.NET application?

  1. Timer Callback

    Timer timer = new Timer(new TimerCallback(MyWorkCallback), HttpContext, 5000, 5000);
    
  2. Thread or ThreadPool

    Thread thread = new Thread(Work);
    thread.IsBackground = true;
    thread.Start();
    
  3. BackgroundWorker

    BackgroundWorker worker = new BackgroundWorker(); 
    worker.DoWork += new DoWorkEventHandler(DoMyWork);
    worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DoMyWork_Completed); 
    worker.RunWorkerAsync();
    
  4. Caching like http://www.codeproject.com/KB/aspnet/ASPNETService.aspx (located in Jeff Atwood's post here)

I need to run multiple background "services" at a given time. One service may run every 5 minutes where another may be once a day. It will never be more than 10 services running at a time.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about multithreading