Currently I'm using Microsoft.Practices.Unity.HierarchicalLifetimeManager as the lifetime manager for my controllers because it calls dispose on the objects it contains. However, it seems that I'm running into cross-threading issues now (multiple request variables are getting mixed up). Reading further into the lifetime manager, it implements a Singleton pattern, which I believe is my problem.
目前我使用Microsoft.Practices.Unity.HierarchicalLifetimeManager作为我的控制器的生命周期管理器,因为它调用它包含的对象上的dispose。但是,现在我似乎遇到了跨线程问题(多个请求变量混淆了)。进一步阅读生命周期管理器,它实现了一个Singleton模式,我认为这是我的问题。
I'm using Unity 2.1. Can any recommend the most appropriate lifetime manager to use with ASP.net MVC controllers, that will call dispose on each of its contained objects at the end of each request?
我正在使用Unity 2.1。是否可以推荐最合适的生命周期管理器与ASP.net MVC控制器一起使用,它将在每个请求结束时调用其包含的每个对象上的dispose?
Thanks so much.
非常感谢。
1 个解决方案
#1
1
I would think any here that don't implement as a singleton should work. You'll need to pick the best for your needs. PerThreadLifetimeManager
sounds pretty good, although it doesn't call Dispose
. However, it will be garbage collected when the thread dies.
我认为任何不实现单身的人都应该有效。您需要选择最适合您需求的产品。 PerThreadLifetimeManager听起来不错,虽然它不会调用Dispose。但是,当线程死亡时,它将被垃圾收集。
#1
1
I would think any here that don't implement as a singleton should work. You'll need to pick the best for your needs. PerThreadLifetimeManager
sounds pretty good, although it doesn't call Dispose
. However, it will be garbage collected when the thread dies.
我认为任何不实现单身的人都应该有效。您需要选择最适合您需求的产品。 PerThreadLifetimeManager听起来不错,虽然它不会调用Dispose。但是,当线程死亡时,它将被垃圾收集。