ASP.NET MVC multi-threading, is it worth it?

I'm a bit confused, my ASP.NET MVC application will be hosted on the server, so does it make sense to make it multithreaded? For example, if I want one thread to do my translations, is that a good idea? Can someone do this for me please? I am a little confused by multithreaded apps for multithreaded apps and web apps.

+4
source share
2 answers

There are a few things to do.

Firstly, each ASP.NET application (MVC or otherwise) is inherently multi-threaded: each request is processed in a separate thread, so you automatically turn on the multi-threaded situation and should take this into account using any shared data access (e.g., statics, etc.) d.).

Another is that with MVC it ​​is especially easy to write asynchronous controller methods, for example:

public async Task<ActionResult> Index(int id)
{
  var model = await SomeMethodThatGetsModelAsync(id);
  return View(model);
}

, , ? ( ) . , SomeMethodThatGetsModel(id) , await ing SomeMethodThatGetsModelAsync(id) . , -, - , . , .

, , - , , .

, , (, -), , .

( , , , , ThreadPool.QueueUserWorkItem Task.Run. ASP.NET, , . , , , , ).

+22

, ?

. , ? , , - , , .

Im -

asp.net .

+1

All Articles