在ASP.Net MVC线程安全 [英] Thread safety in ASP.Net MVC

查看:458
本文介绍了在ASP.Net MVC线程安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑这适用于一般的ASP.Net太多,但我不知道。

I suspect this applies to general ASP.Net too but I am not sure.

如果我有一个控制器的操作方法,说MyController.DoSomethingExciting和三个客户端打在同一时间,它是内在的线程安全的,还是我需要做一些事情,以确保三个并发调用唐'T互相影响?

If I have an action method on a Controller, say MyController.DoSomethingExciting and three clients hit it at "the same time", is it intrinsically thread safe, or do I need to do something to ensure that the three concurrent calls don't interact with each other?

推荐答案

在该方法中的局部变量将每个呼叫。我presume(不知道MVC)的控制器实例是每个请求,所以任何实例成员将是安全的。

Local variables in that method will be per-call. I presume (don't know MVC) that the Controller instances are per-request, so any instance members would be safe.

但是,如果有任何静态或其他共享成员,那么它们不是安全的。

But if there are any static or other shared members, then they are not safe.

这篇关于在ASP.Net MVC线程安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆