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 4126636
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:03:30+00:00 2026-05-21T00:03:30+00:00

I have an ASP.NET MVC 3 (.NET 4) web application. I have a [HttpPost]

  • 0

I have an ASP.NET MVC 3 (.NET 4) web application.

I have a [HttpPost] action method which submit’s some data to the database.

Now, after this method is finishing persisting to the repository, i wish to execute a “background” task (think auditing, or sending an email, etc), where i don’t care about the result (unless an error occurs, in which case i’ll perform logging).

How can/should i fire off this task from my action method?

[HttpPost]
[Authorize]
public ActionResult Create(MyViewModel model)
{
   if (ModelState.IsValid)
   {
      _repo.Save(model); 
      // TODO: Fire off thread
      return RedirectToRoute("Somepage", new { id = model.id });
   }
   return View(model);
}
  • 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-21T00:03:31+00:00Added an answer on May 21, 2026 at 12:03 am

    The new .NET 4 way to do this is with a Task.

    http://msdn.microsoft.com/en-us/library/system.threading.tasks.task.aspx

    Task.Factory.StartNew(MyBackgroundAction);
    

    But for this simple operation where you just want to run it and don’t care about coordinating tasks, it’s just as easy to use the ThreadPool.

    ThreadPool.QueueUserWorkItem(MyBackgroundAction)
    

    You want to avoid creating a new Thread yourself for every action–it’ll take up more resources and is unnecessarily wasteful.

    If you’re background tasks are longer running you might want to setup a producer/consumer queue and have a single or set number of constantly running background threads to run the tasks.

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

Sidebar

Related Questions

I have a asp.net mvc web application an it uses some favicon.ico. Now when
I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7
I have an asp.net mvc application with a route similar to: routes.MapRoute(Blog, {controller}/{action}/{year}/{month}/{day}/{friendlyName}, new
I have an ASP.NET MVC application, when a user clicks on the submit button
I have an ASP.Net MVC web application using forms authentication. I am using OpenID
I have an Asp.Net MVC Web Application that I am developing. I have TeamCity
I have an ASP.NET MVC web application that makes REST style web service calls
I have a Asp.net MVC web application, containing mostly text. I want to put
I have a simple ASP.NET MVC web application that uses NHibernate with FluentNHibernate's auto
I have an ASP.NET 4.0 MVC web application running on IIS 6.0 with a

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.