is wcf rest weboperationcontext.current thread safe?
I'm currently returning a stream from all my WebGet/WebInvoke decorated methods from WCF. And I also get a stream as input. I do this because I want flexibility with response & input content types. This is primarily because I need flexibility wh开发者_运维技巧en parsing the input - it cannot be easily serialized / deserialized.
However I then use the WebOperationContext.Current to set httpstatuscodes. I'm concerned this wouldn't be thread safe though (how would the thread know which context it was processing?)
So my question is - is using WebOperationContext.Current thread-safe under high load conditions?
Does anyone know how the thread and WebOperationContext.Current are linked? Is it using TLS (thread local storage)?
p.
The documentation of WebOperationContext states:
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
This means that invoking Current is thread safe because it is static, but invoking any method on the returned instance will not be guaranteed to be thread safe.
精彩评论