title: Under what context am I running in C#?
body: <p>I was wondering...</p>
  
  <p>When I have a code like this: </p>
  
  <pre><code>lock (obj)
  {
      MyCode.MyAgent();
  }
  </code></pre>
  
  <p>Can <code>MyAgent</code> contain code that <em>recognizes</em> it is running under a <code>lock</code> block?</p>
  
  <p>What about: </p>
  
  <pre><code>for (int i=0;i&lt;5;i++)
  {
     MyCode.MyAgent();
  }
  </code></pre>
  
  <p>Can <code>MyAgent</code> contain code that <em>recognizes</em> it is running under a <code>loop</code> block ?</p>
  
  <p>The same question can be asked for <code>using</code> blocks, <code>unsafe</code> code , etc... - well you get the idea...</p>
  
  <p>Is this possible in C#?  </p>
  
  <p><em>This is just a theoretical question, I'm not trying to achieve anything... just knowledge.</em></p>