8

I'm developing a auction trading system for trading vehicles within the company I work for.

Traders can set alerts and whenever a new listing is submitted I want to use the details of the new listing to search through everybody's alerts for matches, but this shouldn't be time a trader should be waiting to get back confirmation of their successful listing so I want to run it in the background.

My question is, if I mark the function async and not worry about the return will the ASP.NET MVC framework still want to wait for the asynchronous function to end before ending the request?

I know I probably could test this but I'm not sure how, I haven't got too deep in my async books yet.

Thanks.

addy_wils
  • 117
  • 2
  • 8
  • 4
    IIS worker processes can exit at any time, destroying your background work in the process. You can't (easily) have background work in ASP.NET. – usr Mar 15 '14 at 16:08

1 Answers1

4

In ASP.NET you're limited to the boundaries of a given HTTP request/response. You can and should use async/await inside your ASP.NET MVC/Web API controller methods (as described here), this improves the scalability of your web app.

However, it doesn't change the fact the client-side web browser has sent an HTTP request and is still waiting for the HTTP response. Normally, all of the the async operation started by an async controller method should have become completed, before the response is sent to the client.

If you need to span a long-running server-side operation across the boundaries of a single HTTP request, here is a related answer. If your client-side logic requires high frequency updates from the server, Microsoft has SignalR for that.

Community
  • 1
  • 1
noseratio
  • 59,932
  • 34
  • 208
  • 486