1

If my WCF Service has this attribute:

[ServiceBehavior(
     InstanceContextMode = InstanceContextMode.Single,
     ConcurrencyMode = ConcurrencyMode.Multiple)]

How can the following a Singleton work in a call?

System.ServiceModel.Web.WebOperationContext.Current
Jader Dias
  • 88,211
  • 155
  • 421
  • 625

1 Answers1

2

I'm not sure what you're asking exactly... but the operation contexts in WCF (all of them) get tied by default to the execution thread, so whenever you access it (as long as it's within the processing of a WCF request) you'll get the context associated with that requests.

Obviously, your singleton should handle multiple concurrent requests, and it will have access to each request's operation context in the right thread. In other words, most of the time it should just work as expected.

tomasr
  • 13,683
  • 3
  • 38
  • 30
  • So it really works, huh? I'll take your word. I wonder how it works internally, maybe it's Reflector time! – Jader Dias Feb 02 '10 at 21:31
  • It's nothing fancy, it just uses the [ThreadStatic] attribute: http://msdn.microsoft.com/en-us/library/system.threadstaticattribute.aspx – tomasr Feb 03 '10 at 00:47