Fire and Forget with ASP.NET MVC

Viewed 9961

I'm looking for info on best practices for a fire and forget asp.net mvc action ... essentially I want a mobile client to make a call; the server start an async task; and then return to the mobile client as fast as possible.

But I want to make sure that, assuming no exceptions, the async task will complete successfully. There's obviously a few different options:

  • Make a new Thread
  • Queue a work item on the ThreadPool
  • Begin an async delegate call
  • Start a Task

I assume the Task would be the best option here, but wanted to get thoughts from SO.

Edit: to clarify based on a few of the answers already: The client doesn't need a response. I want the HTTP request to complete as fast as possible as soon as the server begins the async task. I know about async patterns on the client, however I want to limit the amount of time the mobile device needs to maintain a connection open. Also, want to avoid having a separate process which polls or is pushed a message (via queue, bus, etc.) because that's overkill. I just want to log something in a database, the client doesn't need to remain connected until that IO is finished.

4 Answers
Related