BundleTable.EnableOptimizations线程安全吗?

BundleTable.EnableOptimizations is thread safe?

我在我的应用程序中添加了一个逻辑以启用调试生产。 我将 debug=true 传递给查询字符串,我在 Application_BeginRequest().

中设置 BundleTable.EnableOptimizations to false (并避免优化我的 js 文件)

我的问题线程安全? 我尝试通过锁定代码来 运行 一些测试,它似乎是线程安全的(即使 BundleTablestatic),但我仍然有些担心。

提前致谢, 里尔

与大多数 .NET 框架一样,答案是

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

(来自 MSDN)

由于 BundleTable 是静态的 class,这意味着所有属性都是线程安全的。

就是说,BundleCollection 本身不是线程安全的 - 只要您不尝试在多个线程中针对同一个请求使用它(这很糟糕),这应该不是问题无论如何有很多原因的想法)。