Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:30:49+00:00 2026-05-23T10:30:49+00:00

I need to run a task repeatedly on an ASP.NET MVC site; it needs

  • 0

I need to run a task repeatedly on an ASP.NET MVC site; it needs to run every time interval (Interval doesn’t matter).

I achieved this by setting a background thread from the Global.asax.cs Application_Start which runs the task, sleeps for time interval and then runs again….and again.

While this works it doesn’t seem like the right way to do this, seems a bit hacky.

So then I replaced it with a Timer object, this doesn’t work reliably – seems others have had problems with it as well – so I’m not going to use this.

This needs to run in the MVC site, it is used for pulling jobs from a queue and rendering them from the Views ready for emailing.

I thought about using the ThreadPool and getting the previous job to leave another job on it’s way out but because these can be long running jobs I’ve read that this can end up not leaving enough threads to deal with web requests through starvation.

Before sticking with the original thread method I thought I’d ask if anyone else knows a better way of doing this.

I hope this makes sense. Effectively what I’m trying to achieve is a heartbeat. Something to act as the consumer part of the producer/consumer pattern in an MVC site.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:30:50+00:00Added an answer on May 23, 2026 at 10:30 am

    Stackoverflow itself uses (or at least used to use) a cunning way of doing this. See here: https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/

    In brief, you do this:

    1. At startup, add an item to the HttpRuntime.Cache with a fixed
      expiration.

    2. When cache item expires, do your work, such as WebRequest or what have
      you.

    3. Re-add the item to the cache with a fixed expiration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run a task in CruiseControl .NET before checking for modification in
I need to run a task every 10 mins from morning 9 AM to
I need to run a task every hour on the hour (00:00, 01:00, 02:00,
I'm trying to run my task immediately, then to run it by time interval.
I have a rake task I need to run as a daily job on
In my Cocoa application I need to run a task that uses unstable unfixable
I need to run a periodic task in an Android application. I currently use
I need to run a macro in an Excel spreadsheet through a schedule task.
I'm making a task-based program that needs to have plugins. Tasks need to have
I have an ASP.NET forms app that allows users to run some management reports.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.