views:

292

answers:

2

Hi

I'm reading about the CallContext class (http://msdn.microsoft.com/en-us/library/system.runtime.remoting.messaging.callcontext.aspx). The documentation says something about "logical threads" and "Thread Local Storage".

What's a logical thread, I didn't know that there existed multiple kinds of threads?

What's a Thread Local Storage, is it a class or a principle of some kind?

I have not been able to find it in on MSDN, but I'm sure it is there some place, so any links would be great :-)

A: 

Thread local storage on msdn

Eric
OK, actually I found this, it says it's for Win32
Karsten
+3  A: 

A logical thread is a concept that dates back to COM, OLE and RPC and also applies to remoting scenarios. A logical thread traces the execution of a synchronous call as it propagates across various boundaries including COM apartments, RPC and remoting boundaries.

This is a really important concept when you consider the possibility that two completely unrelated components might attempt to do operations in the same boundary. Technologies such as COM must be able to distinguish between a new call entering their boundary (apartment) and a completely unrelated call in order to guarantee things like synchronous execution.

Logical threads are fairly difficult to explain in a small SO post. My recomendation is to google / bing for "RPC logical thread" and go from there

Thread Local Storage is quite a bit easier to explain. It's a storage unit that is unique for every thread in a process. The basic idea is that you first allocate a key. You can then query each individual thread for an item with that key. Each thread will hold a different space open for the key and hence have a separate value.

JaredPar
So Thread Local Storage is also just a concept and in .Net it could be achieved by using the CallContext class?
Karsten
@karstenkousgaard, Thread Local Storage is a technology available in .Net, C++ and on most operating systems. It's independent of the CallContext class .
JaredPar