ASP.NET 4.0- Background worker - best practice

10,896

Solution 1

I use http://quartznet.sourceforge.net/index.html for job scheduling and have had great luck with it.

Solution 2

I think the best answer is this article from Haacked.

The Dangers of Implementing Recurring Background Tasks In ASP.NET

In summary IIS is a request driven web server. Which means if there's no one hitting your website nothing will happen. You can work around it but if you want robust background tasks the recommended approach is a Windows Service.

Share:
10,896
sambomartin
Author by

sambomartin

#SOreadytohelp

Updated on July 24, 2022

Comments

  • sambomartin
    sambomartin almost 2 years

    I've implemented a few different types of background workers running under ASP.NET but wondered what the recommended / best practice approach might be.

    In a data store (in this case a mongo db) I have a queue of actions I need to process.

    The queue will grow depending upon certain actions within the ASP.NET MVC app.

    I want to start a background thread / worker thread that continuously processes these queued items.

    Is it as simple as kicking off a background worker in the app's start event, or should it be done on a timer?

    thanks in advance

    sam

  • sambomartin
    sambomartin about 12 years
    thanks for suggestion rboarman but it's a bit of an overkill for me
  • gdp
    gdp about 11 years
    +1 i use quartz in a windows service. Very quick to setup and flexible scheduling.