Best ASP.NET Background Service Implementation
- by Jason N. Gaylord
What's the best implementation for more than one background service in an ASP.NET application?
Timer Callback
Timer timer = new Timer(new TimerCallback(MyWorkCallback), HttpContext, 5000, 5000);
Thread or ThreadPool
Thread thread = new Thread(Work);
thread.IsBackground = true;
thread.Start();
BackgroundWorker
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(DoMyWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DoMyWork_Completed);
worker.RunWorkerAsync();
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.