Release policy for WcfService proxy dependency in object having PerWebRequest lifestyle
Asked Answered
S

1

6

If I have a PerWebRequest object that has a wcf proxy dependency with a PerThread lifestyle, will the container

  • a) use the same proxy instance after the container auto-releases the parent object?
  • b) will the releasing of the PerWebRequest object cause the proxy to be released every time?

If a), then should I release the service explicitly to avoid leakage, or if b), is there any real benefit to using PerThread for the proxy if this is the only place it's being injected?

Sikko answered 11/6, 2012 at 17:29 Comment(0)
H
1

Why would you make it per-thread? Per thread is a very specialised lifestyle and unless you really need it, I would suggest you avoid it.

Make the wcf proxy transient.

You don't have to release it. Here's how it works.

Hardshell answered 29/8, 2012 at 21:43 Comment(4)
Thanks for the reply. I thought it could possibly be more performant to spin up the wcf proxy and have it persist in the container instead of it releasing at the end of every web request and every request on the same thread having to spin it up every time (if the main object that has this dependency is perwebrequest, wouldn't making the service transient require a WAS spin up every time the page is loaded?). Am I incorrect in thinking so?Sikko
I'd call it a premature optimisation.Hardshell
Got it. Thanks. Just for fun, I will ask though. What would be the recommended approach for optimizing for perwebrequest objects with wcf proxy dependencies?Sikko
None. It's not a bottleneck, and if it is, then I would optimise the application code, not how it uses the container.Hardshell

© 2022 - 2024 — McMap. All rights reserved.