Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally, data stored via <code>CallContext.SetData</code> is considered to be thread local. That is, any call to <code>CallContext.GetData</code> will get the data that was set via SetData from the same thread. Data stored via <code>CallContext.LogicalSetData</code> is considered to be "logical thread" local. That is, any data that is stored via <code>CallContext.LogicalSetData</code> will be "flowed" to any child threads. If you call <code>CallContext.LogicalGetData</code> in the same thread or any child threads, you will get the data that was stored by that thread's (or the parent thread's) call to <code>CallContext.LogicalSetData</code>.</p> <p>As @sixlettervariables points out, there are also some specific differences related to Remoting and cross AppDomain calls (maybe cross AppDomain implies Remoting, I don't know, I am not that familiar with Remoting in general).</p> <p>Also as pointed out by @sixlettervariables, by implementing the marker interface ILogicalThreadAffinative on an object and then storing that object using <code>CallContext.SetData</code>, the object will essentially behave as if it had been stored by <code>CallContext.LogicalSetData</code>.</p> <p>Here is a good blog posting from Jeff Richter about using LogicalSetData/LogicalGetData:</p> <p><a href="http://www.wintellect.com/CS/blogs/jeffreyr/archive/2010/09/27/logical-call-context-flowing-data-across-threads-appdomains-and-processes.aspx" rel="noreferrer">http://www.wintellect.com/CS/blogs/jeffreyr/archive/2010/09/27/logical-call-context-flowing-data-across-threads-appdomains-and-processes.aspx</a></p> <p>Here are some more links from here on SO that might shed some more light on CallContext.SetData/GetData, CallContext.LogicalSetData/LogicalGetData, and various forms of thread local storage:</p> <p><a href="https://stackoverflow.com/questions/273301/callcontext-vs-threadstatic">CallContext vs ThreadStatic</a></p> <p><a href="https://stackoverflow.com/questions/3969476/how-to-pass-a-variable-to-another-thread">How to Pass a variable to another Thread</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload