title: Lock() in a static method
body: <p>I have a multi threaded application that writes to a settings xml file using a static method. I want to avoid that the file is being updated twice at the same time (causing accesss/write exception).</p>
  
  <p>How do I do that?</p>
  
  <p>This doesn't work:</p>
  
  <pre><code>namespace Program
  {
      public class Settings
      {
          private static void SetSettingsValue (string settings, string value)
          {
              // make this thread safe to avoid writing to a locked settings xml file
              lock (typeof(Settings))
              {
                  //write data to xml file
              }
          }
      }
  }
  </code></pre>