title: Can I add an attribute to a function to prevent reentry?
body: <p>At the moment, I have some functions which look like this:</p>
  
  <pre><code>private bool inFunction1 = false;
  public void function1()
  {
      if (inFunction1) return;
      inFunction1 = true;
  
      // do stuff which might cause function1 to get called
      ...
  
      inFunction1 = false;
  }
  </code></pre>
  
  <p>I'd like to be able to declare them like this:</p>
  
  <pre><code>[NoReEntry]
  public void function1()
  {
      // do stuff which might cause function1 to get called
      ...
  }
  </code></pre>
  
  <p>Is there an attribute I can add to a function to prevent reentry?  If not, how would I go about making one?  I've heard about AOP attributes that can be used to add code before and after function calls; would they be suitable?</p>