Why does SynchronizedLifetimeManager only release its lock for non-null values

Mar 31, 2011 at 4:38 AM

I have hit an issue with the ContainerControlledLifetimeManager being used in my workflow service. For some reason the lifetime manager is not being assigned a value. There are no constraints on the lifetime managers that they must hold a non-null value, however the GetValue method will only release the lock it has on the manager if the manager contains a non-null value. This has crippled my service as all the threads are waiting on this lock which causes any call to the service to hit a timeout exception.

Why does SynchronizedLifetimeManager only release its lock for non-null values? Is this valid logic?

You can see my workaround at http://www.neovolve.com/post/2011/03/31/Beware-of-lifetime-manager-policy-locks-in-Unity.aspx

Mar 31, 2011 at 5:58 AM

I believe this blog by Chris Tavares explains the reason behind it.  See the Example: CachedLifetimeManager and Multithreading topic of the blog.

I'm just not sure if the scenario you have was taken accounted for when the code was written.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com